[Debian-live-changes] r1289 - in people: . lamby lamby/misc
Chris Lamb
lamby-guest at alioth.debian.org
Sat May 5 23:51:49 UTC 2007
Author: lamby-guest
Date: 2007-05-05 23:51:48 +0000 (Sat, 05 May 2007)
New Revision: 1289
Added:
people/lamby/
people/lamby/misc/
people/lamby/misc/graph-helpers.py
Log:
Create people/lamby - Add graph-helpers.py
Added: people/lamby/misc/graph-helpers.py
===================================================================
--- people/lamby/misc/graph-helpers.py 2007-05-05 23:40:22 UTC (rev 1288)
+++ people/lamby/misc/graph-helpers.py 2007-05-05 23:51:48 UTC (rev 1289)
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+
+# graph-helpers.py
+# Chris Lamb <chris at chris-lamb.co.uk>
+
+helper_dir = "../helpers/"
+highlight = ['lh_chroot', 'lh_source', 'lh_binary', 'lh_build']
+
+import re
+from glob import glob
+from os.path import basename
+from optparse import OptionParser
+
+pattern = re.compile(r'^(lh_.+?) ')
+
+description = """
+This utility generates GraphViz visualisations of
+the live-helper system. Pipe the output of this
+program through dot(1) or twopi(1).
+"""
+
+def main():
+ graph_types = {
+ 'relationships': relationships,
+ 'trail': trail,
+ }
+
+ parser = OptionParser(usage="%prog -t TYPE", description=description)
+ parser.add_option("-t", "--graph-type", dest="graph_type",
+ help="What type of graph to produce (%s)" % ", ".join(graph_types.keys()), metavar="TYPE")
+ (options, args) = parser.parse_args()
+
+ if options.graph_type is None:
+ parser.error("Must specify a graph type (see --help)")
+
+ try:
+ graph_types[options.graph_type]()
+ except KeyError:
+ parser.error("Invalid graph type (expecting one of: %s)" % ", ".join(graph_types.keys()))
+
+# boilerplate graphviz code
+def output(func):
+ def _(*args, **kargs):
+ print "digraph G {"
+ func(*args, **kargs)
+ print "}"
+ return _
+
+ at output
+def relationships():
+ print "ranksep=3; ratio=auto"
+ for helper in glob("%slh_*" % helper_dir):
+ name = basename(helper)
+ for match in gen_matches(helper):
+ print ' "%s" -> "%s" ' % (name, match)
+
+ at output
+def trail():
+ start = "lh_build"
+ def helper(filename):
+ for line in gen_matches(helper_dir + filename):
+ print '-> "%s" ' % line,
+ helper(line)
+
+ print start,
+ helper(start)
+ print ";"
+
+def gen_matches(filename):
+ f = open(filename, 'r')
+ for line in f.xreadlines():
+ match = pattern.match(line)
+ if match:
+ yield match.group(1)
+ f.close()
+
+if __name__ == "__main__":
+ main()
Property changes on: people/lamby/misc/graph-helpers.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the Debian-live-changes
mailing list