puudot/code/puudot.py
Lauri Koskenniemi 0e5a2868b0 Introduce verbose mode and generalize output formats
Added program specific configurations in config.yaml under puudot
and added key for verbose mode. Currently verbose mode prints
'dot' information when running the program.

Refactored puudot.py and graph.py in order to allow easier
addition of output formats.
2025-12-03 20:43:05 +02:00

31 lines
939 B
Python

from db import load_data, load_config
from graph import Graph
import os
DATA_DIR="/data"
CONFIG_FILE="/config.yaml"
FORMAT="pdf"
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'))]
config = load_config(CONFIG_FILE)
for yaml_file in yaml_files:
print(f"Processing {yaml_file}...")
data = load_data(os.path.join(DATA_DIR, yaml_file))
graph = Graph()
graph.set_config(config)
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")
out_file = os.path.join(DATA_DIR, f"{base_name}.{FORMAT}")
graph.make_dot(FORMAT, dot_file, out_file)
if __name__ == "__main__":
main()