Call this python script with python parse.py
to get the diagram for the current diagram or with python parse.py "./directory"
to get it for ./directory
.
Last active
November 14, 2020 15:14
-
-
Save thraizz/b63e688c79d1915d89f9ee179d5065d0 to your computer and use it in GitHub Desktop.
Parse files in directory to a PlantUML Mindmap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import os | |
import sys | |
# Create a container for our collected stringsa | |
UML_STRING = [] | |
# Initialize UML Mindmap | |
UML_STRING.append('@startmindmap') | |
# Get selected dir, if not given use current dir | |
selected_dir = "." | |
filename = "uml_structure.txt" | |
# If we scan the current directory then the starting depth is 1... | |
depth = 1 | |
if(len(sys.argv) > 1): | |
# ... else it is 0 | |
depth = 2 | |
selected_dir = sys.argv[1] | |
# Walk | |
for root, dirs, files in os.walk(selected_dir): | |
path = root.split(os.sep) | |
directory = str((len(path) - depth + 1) * '*' + '[#Orange] ' + os.path.basename(root)) | |
UML_STRING.append(directory) | |
for file in files: | |
UML_STRING.append((len(path) - depth + 2) * '*' + ' ' + file) | |
UML_STRING.append('@endmindmap') | |
# Write content to file | |
with open(filename, 'w') as f: | |
f.write('\n'.join(UML_STRING)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment