puudot/code/puudot.py
Lauri Koskenniemi be4efa0fd2 First test version and data cleanup
Implemented code for the first test version.
Added Docker funtionality.

Define data location in compose and run:
	docker compose up

Removed test data from the repository.
2025-05-24 16:54:19 +03:00

28 lines
860 B
Python

from db import load_yaml
from graph import Graph
import os
#DATA="../data/styrman-blocks.yml"
#DATA="../data/test.yml"
DATA_DIR="/data"
def main():
# Get all YAML files in the data directory
yaml_files = [f for f in os.listdir(DATA_DIR) if f.endswith(('.yaml', '.yml'))]
for yaml_file in yaml_files:
print(f"Processing {yaml_file}...")
data = load_yaml(os.path.join(DATA_DIR, yaml_file))
graph = Graph()
graph.process_blocks(data)
graph.build_dot()
# Use the base name of the YAML file (without extension) as the output name
base_name = os.path.splitext(yaml_file)[0]
dot_file = os.path.join(DATA_DIR, f"{base_name}.gv")
svg_file = os.path.join(DATA_DIR, f"{base_name}.svg")
graph.make_dot("svg", dot_file, svg_file)
if __name__ == "__main__":
main()