Skip to content

Commit

Permalink
Refactored ltm and jtg applications into one simpler app
Browse files Browse the repository at this point in the history
  • Loading branch information
rob committed May 5, 2023
1 parent f2365cb commit 33a572f
Show file tree
Hide file tree
Showing 8 changed files with 657 additions and 309 deletions.
33 changes: 19 additions & 14 deletions src/jtg.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ def prepDoc(doc):


def main(
generateArchDiagram=True, markdown=False, printLabels=False, linkCounters=True, singleScene=False
generateArchDiagram=True,
markdown=False,
printLabels=False,
linkCounters=True,
singleScene=False,
):
doc = json.loads(sys.stdin.read())
doc = prepDoc(doc)
Expand All @@ -136,14 +140,14 @@ def main(
graph = genGraph(
doc, sceneName, linkCounters=linkCounters, printLabels=printLabels
)

fileName = f"output/{sceneName}.dot"
if sceneName == ARCH:
graph.write(fileName, compoundLinks=True)
else:
graph.write(fileName)

graphviz.render('dot', 'png', fileName).replace('\\', '/')
graphviz.render("dot", "png", fileName).replace("\\", "/")

if markdown:
print(f"## {sceneName}")
Expand All @@ -152,7 +156,9 @@ def main(
print("\n| Actor | Description |")
print("| --- | ---- |")
for actor in doc["actors"].keys():
print(f"| {actor} | {doc['actors'][actor]['description'] if 'description' in doc['actors'][actor] else '-'} |")
print(
f"| {actor} | {doc['actors'][actor]['description'] if 'description' in doc['actors'][actor] else '-'} |"
)
print("\n")

if sceneName != ARCH:
Expand All @@ -166,7 +172,6 @@ def main(
ctr += 1
print("\n")



if __name__ == "__main__":
# TODO argument handling
Expand All @@ -179,7 +184,8 @@ def main(
}

if "-h" in sys.argv or "--help" in sys.argv:
print("""
print(
"""
Generate architecture diagrams and markdown reports from JSON files
-h \t\t Print this help
Expand All @@ -188,20 +194,21 @@ def main(
-markdown \t Generate Markdown output that inlcudes generated diagrams
-label \t\t Include data strings in edge labels
-number \t Number each dataflow
""")
"""
)
sys.exit(0)

if "-arch" in sys.argv:
parms["generateArchDiagram"] = True

if "-markdown" in sys.argv:
parms["markdown"] = True

if "-label" in sys.argv:
parms["printLabels"] = True

if "-number" in sys.argv:
parms["linkCounters"] = True
parms["linkCounters"] = True

if "-single" in sys.argv:
parms["singleScene"] = True
Expand All @@ -214,7 +221,5 @@ def main(
if "printLabels" in parms:
print("Error: Cannot use '-label' and '-single' in the same command")
sys.exit(-1)

main(**parms)


main(**parms)
Loading

0 comments on commit 33a572f

Please sign in to comment.