graph: add some minimal documentation
This commit is contained in:
parent
25e57f272c
commit
9db9212ed7
22
graph.py
22
graph.py
@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/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 satisfactory
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -8,6 +13,14 @@ from typing import Iterable
|
|||||||
|
|
||||||
|
|
||||||
def graph(cookbook: satisfactory.Cookbook, targets: Iterable[str]):
|
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 {")
|
print("digraph G {")
|
||||||
|
|
||||||
seen = set()
|
seen = set()
|
||||||
@ -22,17 +35,10 @@ def graph(cookbook: satisfactory.Cookbook, targets: Iterable[str]):
|
|||||||
remain.add(need)
|
remain.add(need)
|
||||||
|
|
||||||
seen.add(output)
|
seen.add(output)
|
||||||
|
|
||||||
print("}")
|
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__':
|
if __name__ == '__main__':
|
||||||
def main():
|
def main():
|
||||||
import argparse
|
import argparse
|
||||||
|
Loading…
Reference in New Issue
Block a user