Skip to content

Commit

Permalink
add abs code
Browse files Browse the repository at this point in the history
  • Loading branch information
paulKobi committed May 30, 2023
0 parents commit e477df0
Show file tree
Hide file tree
Showing 3 changed files with 593 additions and 0 deletions.
25 changes: 25 additions & 0 deletions code/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

.DEFAULT_GOAL := run

.PHONY: compile
compile: journey.abs ## Compile the model
absc -e journey.abs

.PHONY: run
run: compile ## Compile and run the model
gen/erl/run | python extract-summary-files.py

.PHONY: serve
serve: compile ## Compile and run the model, including web api on port 8080
gen/erl/run -p 8080

.PHONY: clean
clean: ## Clean build artifacts
rm -rf gen/ *.csv

# "make print-PATH" prints the value of PATH, etc.
print-%: ; @echo $*=$($*)

.PHONY: help
help: ## Output this help message
@grep -E '^[a-zA-Z_%-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
30 changes: 30 additions & 0 deletions code/extract-summary-files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re
import sys

def write_to_file(filename, lines):
with open(filename, 'w') as file:
for line in lines:
file.write(line)

def main():
current_file = None
current_lines = []

filename_pattern = re.compile(r"===== ([a-zA-Z0-9._]+) =====")

for line in sys.stdin:
match = filename_pattern.match(line.strip())
if match:
if current_file is not None:
write_to_file(current_file, current_lines)
current_lines = []

current_file = match.group(1) # Extract the filename from the matched pattern
else:
current_lines.append(line)

if current_file is not None:
write_to_file(current_file, current_lines)

if __name__ == '__main__':
main()
Loading

0 comments on commit e477df0

Please sign in to comment.