From 9db9212ed7f2f1b71ce2a5a9bccf04783468450e Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 14 Jul 2019 13:25:37 +1000 Subject: [PATCH] graph: add some minimal documentation --- graph.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/graph.py b/graph.py index 34f129b..1568d09 100755 --- a/graph.py +++ b/graph.py @@ -1,5 +1,10 @@ #!/usr/bin/env python3 +""" +This script takes a target item and produces GraphViz formatted output that +describes the gross production dependencies required to produce the item. +""" + import satisfactory import os @@ -8,6 +13,14 @@ from typing import Iterable def graph(cookbook: satisfactory.Cookbook, targets: Iterable[str]): + """ + Output the directed graph representing the production chain needed to + produce all the provided targets. + + :param cookbook: + :param targets: + :return: + """ print("digraph G {") seen = set() @@ -22,17 +35,10 @@ def graph(cookbook: satisfactory.Cookbook, targets: Iterable[str]): remain.add(need) seen.add(output) + print("}") -def graph_all(recipes: dict) -> None: - graph(recipes, recipes.all()) - - -def graph_one(recipes: dict, target: str) -> None: - graph(recipes, [target]) - - if __name__ == '__main__': def main(): import argparse