diff options
Diffstat (limited to 'depgraph2dot.py')
-rw-r--r-- | depgraph2dot.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/depgraph2dot.py b/depgraph2dot.py index bbebf18..050da44 100644 --- a/depgraph2dot.py +++ b/depgraph2dot.py | |||
@@ -24,7 +24,7 @@ import sys, getopt, colorsys, imp, md5 | |||
24 | 24 | ||
25 | class pydepgraphdot: | 25 | class pydepgraphdot: |
26 | 26 | ||
27 | def main(self,argv): | 27 | def main(self,argv): |
28 | opts,args = getopt.getopt(argv,'',['mono']) | 28 | opts,args = getopt.getopt(argv,'',['mono']) |
29 | self.colored = 1 | 29 | self.colored = 1 |
30 | for o,v in opts: | 30 | for o,v in opts: |
@@ -35,7 +35,7 @@ class pydepgraphdot: | |||
35 | def fix(self,s): | 35 | def fix(self,s): |
36 | # Convert a module name to a syntactically correct node name | 36 | # Convert a module name to a syntactically correct node name |
37 | return s.replace('.','_') | 37 | return s.replace('.','_') |
38 | 38 | ||
39 | def render(self): | 39 | def render(self): |
40 | p,t = self.get_data() | 40 | p,t = self.get_data() |
41 | 41 | ||
@@ -44,9 +44,9 @@ class pydepgraphdot: | |||
44 | for v in d.keys(): | 44 | for v in d.keys(): |
45 | if not p.has_key(v): | 45 | if not p.has_key(v): |
46 | p[v] = {} | 46 | p[v] = {} |
47 | 47 | ||
48 | f = self.get_output_file() | 48 | f = self.get_output_file() |
49 | 49 | ||
50 | f.write('digraph G {\n') | 50 | f.write('digraph G {\n') |
51 | #f.write('concentrate = true;\n') | 51 | #f.write('concentrate = true;\n') |
52 | #f.write('ordering = out;\n') | 52 | #f.write('ordering = out;\n') |
@@ -86,7 +86,7 @@ class pydepgraphdot: | |||
86 | if self.toocommon(k,type): | 86 | if self.toocommon(k,type): |
87 | a.append('peripheries=2') | 87 | a.append('peripheries=2') |
88 | return a | 88 | return a |
89 | 89 | ||
90 | def edge_attributes(self,k,v): | 90 | def edge_attributes(self,k,v): |
91 | a = [] | 91 | a = [] |
92 | weight = self.weight(k,v) | 92 | weight = self.weight(k,v) |
@@ -96,11 +96,11 @@ class pydepgraphdot: | |||
96 | if length: | 96 | if length: |
97 | a.append('minlen=%d' % length) | 97 | a.append('minlen=%d' % length) |
98 | return a | 98 | return a |
99 | 99 | ||
100 | def get_data(self): | 100 | def get_data(self): |
101 | t = eval(sys.stdin.read()) | 101 | t = eval(sys.stdin.read()) |
102 | return t['depgraph'],t['types'] | 102 | return t['depgraph'],t['types'] |
103 | 103 | ||
104 | def get_output_file(self): | 104 | def get_output_file(self): |
105 | return sys.stdout | 105 | return sys.stdout |
106 | 106 | ||
@@ -133,11 +133,11 @@ class pydepgraphdot: | |||
133 | # dont draw references to packages. | 133 | # dont draw references to packages. |
134 | return 1 | 134 | return 1 |
135 | return 0 | 135 | return 0 |
136 | 136 | ||
137 | def weight(self,a,b): | 137 | def weight(self,a,b): |
138 | # Return the weight of the dependency from a to b. Higher weights | 138 | # Return the weight of the dependency from a to b. Higher weights |
139 | # usually have shorter straighter edges. Return 1 if it has normal weight. | 139 | # usually have shorter straighter edges. Return 1 if it has normal weight. |
140 | # A value of 4 is usually good for ensuring that a related pair of modules | 140 | # A value of 4 is usually good for ensuring that a related pair of modules |
141 | # are drawn next to each other. This is a default policy - please override. | 141 | # are drawn next to each other. This is a default policy - please override. |
142 | # | 142 | # |
143 | if b.split('.')[-1].startswith('_'): | 143 | if b.split('.')[-1].startswith('_'): |
@@ -146,7 +146,7 @@ class pydepgraphdot: | |||
146 | # together | 146 | # together |
147 | return 4 | 147 | return 4 |
148 | return 1 | 148 | return 1 |
149 | 149 | ||
150 | def alien(self,a,b): | 150 | def alien(self,a,b): |
151 | # Return non-zero if references to this module are strange, and should be drawn | 151 | # Return non-zero if references to this module are strange, and should be drawn |
152 | # extra-long. the value defines the length, in rank. This is also good for putting some | 152 | # extra-long. the value defines the length, in rank. This is also good for putting some |
@@ -166,7 +166,7 @@ class pydepgraphdot: | |||
166 | # same package have the same color. Unpackaged modules are grey | 166 | # same package have the same color. Unpackaged modules are grey |
167 | t = self.normalise_module_name_for_hash_coloring(s,type) | 167 | t = self.normalise_module_name_for_hash_coloring(s,type) |
168 | return self.color_from_name(t) | 168 | return self.color_from_name(t) |
169 | 169 | ||
170 | def normalise_module_name_for_hash_coloring(self,s,type): | 170 | def normalise_module_name_for_hash_coloring(self,s,type): |
171 | if type==imp.PKG_DIRECTORY: | 171 | if type==imp.PKG_DIRECTORY: |
172 | return s | 172 | return s |
@@ -176,7 +176,7 @@ class pydepgraphdot: | |||
176 | return '' | 176 | return '' |
177 | else: | 177 | else: |
178 | return s[:i] | 178 | return s[:i] |
179 | 179 | ||
180 | def color_from_name(self,name): | 180 | def color_from_name(self,name): |
181 | n = md5.md5(name).digest() | 181 | n = md5.md5(name).digest() |
182 | hf = float(ord(n[0])+ord(n[1])*0xff)/0xffff | 182 | hf = float(ord(n[0])+ord(n[1])*0xff)/0xffff |