pkgdotter.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 '''
3 This a dirty hack
4 '''
5 
6 import sys
7 
8 from collections import defaultdict
9 
10 class Faker(object):
11  def __init__(self):
12 
13  self.deps = dict()
14  for typ in 'lib app test'.split():
15  self.deps[typ] = defaultdict(set)
16 
17  def register(self, typ, name, uselst):
18  if type(uselst) == type(""):
19  uselst = uselst.split()
20  for one in uselst:
21  self.deps[typ][name].add(one)
22 
23 
24  def smplpkg(self, name, use='', test_use='', app_use=''):
25  '''
26  Fake being the waf bld method of the same name. The 'use'
27  args can be litteral lists or space separated strings and hold
28  names of packages on which the 'name' pacakge depends.
29  '''
30  self.register('lib', name, use)
31 
32  self.register('app', name, use)
33  self.register('app', name, app_use)
34 
35  self.register('test', name, use)
36  self.register('test', name, test_use)
37 
38  def dot(self, typ):
39  preamble=[
40  'node[shape=box];',
41  'label="Wire Cell Package Dependencies for view: %s";' % typ.upper(),
42  ]
43 
44  edges = list()
45  d = self.deps[typ]
46  exts = set()
47  for n,deps in d.items():
48  for dep in deps:
49  edges.append('%s -> %s;' % (n, dep))
50  if not dep.startswith("WireCell"):
51  exts.add(dep)
52 
53  exts = ','.join(list(exts))
54  preamble.append('{rank=same; %s}' % exts)
55 
56  preamble = '\n\t'.join(preamble)
57  body = '\n\t'.join(edges)
58  return 'digraph %s {\n\t%s\n\t%s\n}\n' % (typ, preamble, body)
59 
60 
61 bld = Faker()
62 
63 which = sys.argv[1]
64 wscrip_builds = sys.argv[2:]
65 
66 for wb in wscrip_builds:
67  execfile (wb)
68 
69 print (bld.dot(which))
70 
Coord add(Coord c1, Coord c2)
Definition: restypedef.cpp:23
def smplpkg(self, name, use='', test_use='', app_use='')
Definition: pkgdotter.py:24
Proc * join(Pipeline &pipeline, Proc *src, Proc *dst)
Definition: GenPipeline.h:218
def dot(self, typ)
Definition: pkgdotter.py:38
def register(self, typ, name, uselst)
Definition: pkgdotter.py:17
def __init__(self)
Definition: pkgdotter.py:11
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35