aboutsummaryrefslogtreecommitdiff
path: root/use2dot/change_graph.py
diff options
context:
space:
mode:
Diffstat (limited to 'use2dot/change_graph.py')
-rwxr-xr-xuse2dot/change_graph.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/use2dot/change_graph.py b/use2dot/change_graph.py
new file mode 100755
index 00000000..50d1c34f
--- /dev/null
+++ b/use2dot/change_graph.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+import re
+import colorsys
+import hashlib
+import sys
+
+def md5(str):
+ return hashlib.md5(str.encode("UTF-8")).hexdigest()
+
+def rgb(str):
+ return md5(str)[0:6]
+
+def main(args):
+
+ if len(args) < 3:
+ print("Usage: ./change_graph.py <infile> <outfile>")
+ return
+
+ [_, infile, outfile, *rest] = args
+
+ with open(infile) as f:
+ lines = f.readlines()
+ # [3:-1]
+
+ f = open(outfile, 'w')
+
+ for line in lines:
+ m = re.search('^( *"\(([^)]*)\)" -> "(\([^)]*\))");', line)
+ if m:
+ f.write(f'{m.group(1)} [color="#{rgb(m.group(2))}"];\n')
+ else:
+ f.write(line)
+ # colorsys.hsv_to_rgb(
+
+
+# "(server macro)" -> "(ice-9 regex)";
+
+if __name__ == "__main__":
+ main(sys.argv)