Created
August 11, 2015 14:24
-
-
Save fritschy/2c775c34dc5514ca3b9a to your computer and use it in GitHub Desktop.
Create a graphviz digraph file from a number of EGL_*.txt files
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
#!/usr/bin/env python3 | |
import sys | |
def main(): | |
out = {} | |
for fn in sys.argv[1:]: | |
ext=fn.split('.',1)[0] | |
with open(fn) as inp: | |
in_deps=False | |
for l in map(str.rstrip, inp): | |
if len(l) < 1: | |
continue | |
elif l.startswith("Dependencies"): | |
in_deps=True | |
elif in_deps and not l.startswith(' '): | |
break | |
elif not in_deps: | |
continue | |
for word in filter(lambda x: x.startswith("EGL_") and x != ext, map(lambda x: x.split('.', 1)[0], l.split(' '))): | |
dep = (ext, word) | |
if not out.get(dep,False): | |
out[dep] = True | |
print("digraph {") | |
print("\n".join(map(lambda x: " %s -> %s" % x, out.keys()))) | |
print("}") | |
__name__ == '__main__' and main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment