-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle_uml_class_diagram.py
More file actions
42 lines (28 loc) · 989 Bytes
/
style_uml_class_diagram.py
File metadata and controls
42 lines (28 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from graphviz import Source
import re
import argparse
def add_style(filename: str) -> str:
FONTNAME = "Roboto-Regular"
FONTCOLOR = "#2F2F2F"
SHAPECOLOR = "#2F2F2F"
MARK = '"'
style = fr"\1color={MARK}{SHAPECOLOR}{MARK}, fontname={MARK}{FONTNAME}{MARK}, fontcolor={MARK}{FONTCOLOR}{MARK}, "
s = Source.from_file(filename).source
s = re.sub(r"(\[)(?=label)", style, s)
with open(filename, "w") as dot_file:
dot_file.write(s)
return "\n\N{sparkles} \N{memo} Done! \N{sparkles}\n"
if __name__ == "__main__":
FILENAME = "classes.dot"
parser = argparse.ArgumentParser(
description="Style the UML class diagram generated with Pyreverse.",
epilog="Powered by Graphviz and Pyreverse.",
)
parser.add_argument(
"-f",
"--filename",
help="The filename of the UML class diagram DOT file.",
default=FILENAME,
)
args = parser.parse_args()
print(add_style(args.filename))