Merge lp:~knitzsche/dotdepends/bug-1023095 into lp:dotdepends
- bug-1023095
- Merge into trunk
Proposed by
Kyle Nitzsche
Status: | Merged |
---|---|
Merged at revision: | 70 |
Proposed branch: | lp:~knitzsche/dotdepends/bug-1023095 |
Merge into: | lp:dotdepends |
Diff against target: |
316 lines (+48/-66) 5 files modified
Dotdepends/Dot.py (+17/-10) debian/changelog (+10/-0) debian/rules (+0/-1) usr/bin/dotdepends (+6/-12) usr/bin/dotdepends-merge (+15/-43) |
To merge this branch: | bzr merge lp:~knitzsche/dotdepends/bug-1023095 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mike Carifio | Approve | ||
Review via email: mp+114254@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 70. By Kyle Nitzsche
-
* dotdepends-merge: fixed some blurry logic on setting node borders red
* rest is mostly code cleanup
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Dotdepends/Dot.py' | |||
2 | --- Dotdepends/Dot.py 2012-07-04 00:40:59 +0000 | |||
3 | +++ Dotdepends/Dot.py 2012-07-10 22:00:25 +0000 | |||
4 | @@ -92,7 +92,7 @@ | |||
5 | 92 | def get_content(self): | 92 | def get_content(self): |
6 | 93 | """Returns the content of the dot file as a list of lines. | 93 | """Returns the content of the dot file as a list of lines. |
7 | 94 | 94 | ||
9 | 95 | Content is the dot file with out the header or footer. | 95 | Content is the dot file without the header or footer. |
10 | 96 | """ | 96 | """ |
11 | 97 | content = [] | 97 | content = [] |
12 | 98 | for line in self.dot: | 98 | for line in self.dot: |
13 | @@ -106,7 +106,7 @@ | |||
14 | 106 | def get_joins(self): | 106 | def get_joins(self): |
15 | 107 | """Returns the 'join' lines from the dot file as a list of lists [[]]. | 107 | """Returns the 'join' lines from the dot file as a list of lists [[]]. |
16 | 108 | 108 | ||
18 | 109 | Join lines are edgesi between nodes, specifically: lnode -> rnode. | 109 | Join lines are edges between nodes, specifically: lnode -> rnode. |
19 | 110 | There may be a style after the rnode: lnode -> rnode style. Each | 110 | There may be a style after the rnode: lnode -> rnode style. Each |
20 | 111 | top-level list represents a join line. This contains a list containing | 111 | top-level list represents a join line. This contains a list containing |
21 | 112 | the items in the line as follows: [lnode, rnode, style(if any)] | 112 | the items in the line as follows: [lnode, rnode, style(if any)] |
22 | @@ -130,8 +130,9 @@ | |||
23 | 130 | def get_nodes(self): | 130 | def get_nodes(self): |
24 | 131 | """Returns a dictionary of nodes in the dot file where the key is the | 131 | """Returns a dictionary of nodes in the dot file where the key is the |
25 | 132 | node name and the value is the style, if any, as a string, without the | 132 | node name and the value is the style, if any, as a string, without the |
27 | 133 | closing square brackets. | 133 | enclosing square brackets one finds in a dot file. |
28 | 134 | """ | 134 | """ |
29 | 135 | |||
30 | 135 | nodes = dict() | 136 | nodes = dict() |
31 | 136 | node_lines = [] | 137 | node_lines = [] |
32 | 137 | for line in self.content: | 138 | for line in self.content: |
33 | @@ -151,6 +152,7 @@ | |||
34 | 151 | where the key is lnode name and the value is the number of times the | 152 | where the key is lnode name and the value is the number of times the |
35 | 152 | lnode exists as an lnode in the dot file. | 153 | lnode exists as an lnode in the dot file. |
36 | 153 | """ | 154 | """ |
37 | 155 | |||
38 | 154 | lnodes = dict() | 156 | lnodes = dict() |
39 | 155 | for join in self.joins: | 157 | for join in self.joins: |
40 | 156 | if len(join) == 0: continue | 158 | if len(join) == 0: continue |
41 | @@ -166,6 +168,7 @@ | |||
42 | 166 | where the key is rnode name and the value is the number of times the | 168 | where the key is rnode name and the value is the number of times the |
43 | 167 | rnode exists as an rnode in the dot file. | 169 | rnode exists as an rnode in the dot file. |
44 | 168 | """ | 170 | """ |
45 | 171 | |||
46 | 169 | rnodes = dict() | 172 | rnodes = dict() |
47 | 170 | for join in self.joins: | 173 | for join in self.joins: |
48 | 171 | if len(join) == 0: continue | 174 | if len(join) == 0: continue |
49 | @@ -177,7 +180,7 @@ | |||
50 | 177 | return rnodes | 180 | return rnodes |
51 | 178 | 181 | ||
52 | 179 | def get_popular_lnodes(self, popularity): | 182 | def get_popular_lnodes(self, popularity): |
54 | 180 | """Returns a dictionary of lnodes where all lnodes exit as lnodes in | 183 | """Returns a dictionary of lnodes where all lnodes exiist as lnodes in |
55 | 181 | the dot at least as many times as specified by the 'popularity' arg. | 184 | the dot at least as many times as specified by the 'popularity' arg. |
56 | 182 | """ | 185 | """ |
57 | 183 | popular = dict() | 186 | popular = dict() |
58 | @@ -215,7 +218,8 @@ | |||
59 | 215 | family in order to make large graphs smaller and easier to comprehend. | 218 | family in order to make large graphs smaller and easier to comprehend. |
60 | 216 | 219 | ||
61 | 217 | A family of nodes is a set of nodes that have no lnodes outside of the | 220 | A family of nodes is a set of nodes that have no lnodes outside of the |
63 | 218 | family (except for the root node of the family which does have lnodes). | 221 | family (except for the root node of the family which does have lnodes |
64 | 222 | outside of the family). | ||
65 | 219 | """ | 223 | """ |
66 | 220 | 224 | ||
67 | 221 | rnodes = self.get_rnodes_for_lnode(node) | 225 | rnodes = self.get_rnodes_for_lnode(node) |
68 | @@ -323,8 +327,9 @@ | |||
69 | 323 | where the key is node and the value is an approriately amended style. | 327 | where the key is node and the value is an approriately amended style. |
70 | 324 | 328 | ||
71 | 325 | Nodes internal to families that are not the family top node are | 329 | Nodes internal to families that are not the family top node are |
73 | 326 | dropped as part of family summariation. | 330 | dropped as part of family summarization. |
74 | 327 | """ | 331 | """ |
75 | 332 | |||
76 | 328 | n_nodes = dict() | 333 | n_nodes = dict() |
77 | 329 | for node in self.nodes.keys(): | 334 | for node in self.nodes.keys(): |
78 | 330 | if node in f_internal_nodes: | 335 | if node in f_internal_nodes: |
79 | @@ -338,11 +343,13 @@ | |||
80 | 338 | if not _s.startswith("label="): | 343 | if not _s.startswith("label="): |
81 | 339 | n_styles+= _s + ',' | 344 | n_styles+= _s + ',' |
82 | 340 | if style.find('fillcolor=blue') >-1:#this is the root node | 345 | if style.find('fillcolor=blue') >-1:#this is the root node |
85 | 341 | style = n_styles + \ | 346 | style = n_styles |
86 | 342 | "fillcolor=blue,style=filled,shape=%s" % self.shape | 347 | style += "fillcolor=blue,style=filled,shape=" |
87 | 348 | style += self.shape | ||
88 | 343 | else: | 349 | else: |
91 | 344 | style = n_styles + \ | 350 | style = n_styles |
92 | 345 | "fillcolor=yellow,style=filled,shape=%s" % self.shape | 351 | style += "fillcolor=yellow,style=filled,shape=" |
93 | 352 | style += self.shape | ||
94 | 346 | node = "%s_Family_%d" % (node, len(fams[fam])) | 353 | node = "%s_Family_%d" % (node, len(fams[fam])) |
95 | 347 | if node != fam and node in fams[fam]: | 354 | if node != fam and node in fams[fam]: |
96 | 348 | continue | 355 | continue |
97 | 349 | 356 | ||
98 | === modified file 'debian/changelog' | |||
99 | --- debian/changelog 2012-07-09 18:43:48 +0000 | |||
100 | +++ debian/changelog 2012-07-10 22:00:25 +0000 | |||
101 | @@ -1,3 +1,13 @@ | |||
102 | 1 | dotdepends (0.3.15kyle1) UNRELEASED; urgency=low | ||
103 | 2 | |||
104 | 3 | * redundant 'color="red"' styles in nodes in generated pkg-DETAIL.dot files | ||
105 | 4 | caused dotdepends-merge on such dot files to incorrected draw some node | ||
106 | 5 | borders, colorwise. fixes LP: #1023095 | ||
107 | 6 | * dotdepends-merge: fixed some blurry logic on setting node borders red | ||
108 | 7 | * rest is mostly code cleanup | ||
109 | 8 | |||
110 | 9 | -- Kyle Nitzsche <kyle.nitzsche@canonical.com> Tue, 10 Jul 2012 17:53:20 -0400 | ||
111 | 10 | |||
112 | 1 | dotdepends (0.3.15) precise; urgency=low | 11 | dotdepends (0.3.15) precise; urgency=low |
113 | 2 | 12 | ||
114 | 3 | * fix recent failures of -d option on dotdepends (disables auto running of | 13 | * fix recent failures of -d option on dotdepends (disables auto running of |
115 | 4 | 14 | ||
116 | === modified file 'debian/rules' | |||
117 | --- debian/rules 2012-06-21 21:33:13 +0000 | |||
118 | +++ debian/rules 2012-07-10 22:00:25 +0000 | |||
119 | @@ -6,7 +6,6 @@ | |||
120 | 6 | override_dh_auto_install: | 6 | override_dh_auto_install: |
121 | 7 | python ./setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr --install-layout=deb | 7 | python ./setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr --install-layout=deb |
122 | 8 | 8 | ||
123 | 9 | |||
124 | 10 | override_dh_auto_clean: | 9 | override_dh_auto_clean: |
125 | 11 | -find . -name '*.py[co]' | xargs rm -f | 10 | -find . -name '*.py[co]' | xargs rm -f |
126 | 12 | 11 | ||
127 | 13 | 12 | ||
128 | === modified file 'usr/bin/dotdepends' | |||
129 | --- usr/bin/dotdepends 2012-07-09 18:14:03 +0000 | |||
130 | +++ usr/bin/dotdepends 2012-07-10 22:00:25 +0000 | |||
131 | @@ -239,8 +239,6 @@ | |||
132 | 239 | ] | 239 | ] |
133 | 240 | if opt.dont_run_dot: | 240 | if opt.dont_run_dot: |
134 | 241 | cmd.append('-d') | 241 | cmd.append('-d') |
135 | 242 | if opt.installed: | ||
136 | 243 | cmd.append('-i') | ||
137 | 244 | 242 | ||
138 | 245 | # output_dir_created is True iff the subprocess below will create (and populate) | 243 | # output_dir_created is True iff the subprocess below will create (and populate) |
139 | 246 | # a new directory opt.output_dir. | 244 | # a new directory opt.output_dir. |
140 | @@ -268,17 +266,14 @@ | |||
141 | 268 | if opt.dont_run_dot: | 266 | if opt.dont_run_dot: |
142 | 269 | cmd.append('-d') | 267 | cmd.append('-d') |
143 | 270 | 268 | ||
144 | 271 | if opt.installed and opt.mode == 'rdepends': | ||
145 | 272 | cmd.append('-i') | ||
146 | 273 | |||
147 | 274 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE) | 269 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
148 | 275 | f2 = p.communicate() | 270 | f2 = p.communicate() |
149 | 276 | # Did the process error? | 271 | # Did the process error? |
150 | 277 | if p.returncode > 0 or (f2[1] is not None and f2[1].startswith('Error')): | 272 | if p.returncode > 0 or (f2[1] is not None and f2[1].startswith('Error')): |
151 | 278 | # Yes, pass the error along | 273 | # Yes, pass the error along |
152 | 279 | print >> sys.stderr, f2[1] | 274 | print >> sys.stderr, f2[1] |
155 | 280 | exit(1) | 275 | sys.exit(1) |
156 | 281 | 276 | ||
157 | 282 | f2dot = f2[0].rstrip('.png\n') | 277 | f2dot = f2[0].rstrip('.png\n') |
158 | 283 | if not f2dot.endswith(".dot"): | 278 | if not f2dot.endswith(".dot"): |
159 | 284 | f2dot += ".dot" | 279 | f2dot += ".dot" |
160 | @@ -299,7 +294,7 @@ | |||
161 | 299 | 294 | ||
162 | 300 | _f3 = [] | 295 | _f3 = [] |
163 | 301 | for line in f3: | 296 | for line in f3: |
165 | 302 | if line.find("->") > -1: | 297 | if line.find("->") > -1: |
166 | 303 | _f3.append(line) | 298 | _f3.append(line) |
167 | 304 | continue | 299 | continue |
168 | 305 | if line.find("{") > -1: | 300 | if line.find("{") > -1: |
169 | @@ -312,7 +307,8 @@ | |||
170 | 312 | _line = line.lstrip() | 307 | _line = line.lstrip() |
171 | 313 | _pkg = _line.split(" ")[0] | 308 | _pkg = _line.split(" ")[0] |
172 | 314 | if _pkg in adds: | 309 | if _pkg in adds: |
174 | 315 | line = line.replace("[", '[color="red",') | 310 | if line.find('color="red"') == -1: |
175 | 311 | line = line.replace("[", '[color="red",') | ||
176 | 316 | _f3.append(line) | 312 | _f3.append(line) |
177 | 317 | 313 | ||
178 | 318 | _f = open(f3dot, 'w') | 314 | _f = open(f3dot, 'w') |
179 | @@ -321,7 +317,6 @@ | |||
180 | 321 | _f.flush() | 317 | _f.flush() |
181 | 322 | _f.close() | 318 | _f.close() |
182 | 323 | 319 | ||
183 | 324 | |||
184 | 325 | if opt.dont_run_dot: | 320 | if opt.dont_run_dot: |
185 | 326 | print f3dot | 321 | print f3dot |
186 | 327 | else: | 322 | else: |
187 | @@ -349,7 +344,6 @@ | |||
188 | 349 | 344 | ||
189 | 350 | sys.exit(0) | 345 | sys.exit(0) |
190 | 351 | 346 | ||
191 | 352 | |||
192 | 353 | deps = dict([]) | 347 | deps = dict([]) |
193 | 354 | recommends = dict([]) | 348 | recommends = dict([]) |
194 | 355 | onlyRecs = [] | 349 | onlyRecs = [] |
195 | @@ -393,7 +387,7 @@ | |||
196 | 393 | p1 = replacement(k) | 387 | p1 = replacement(k) |
197 | 394 | if p1 == "label": continue | 388 | if p1 == "label": continue |
198 | 395 | p2 = replacement(v) | 389 | p2 = replacement(v) |
200 | 396 | # made joins ('edges') | 390 | # make joins ('edges') |
201 | 397 | if opt.mode == "rdepends": | 391 | if opt.mode == "rdepends": |
202 | 398 | edge = '%s -> %s\n' % (p2,p1) | 392 | edge = '%s -> %s\n' % (p2,p1) |
203 | 399 | elif opt.mode == "depends": | 393 | elif opt.mode == "depends": |
204 | 400 | 394 | ||
205 | === modified file 'usr/bin/dotdepends-merge' | |||
206 | --- usr/bin/dotdepends-merge 2012-07-09 14:42:21 +0000 | |||
207 | +++ usr/bin/dotdepends-merge 2012-07-10 22:00:25 +0000 | |||
208 | @@ -79,33 +79,19 @@ | |||
209 | 79 | _n1 = addShapes(n1,s1,c1) | 79 | _n1 = addShapes(n1,s1,c1) |
210 | 80 | _n2 = addShapes(n2,s2,c2) | 80 | _n2 = addShapes(n2,s2,c2) |
211 | 81 | 81 | ||
213 | 82 | _shape='shape="diamond",fillcolor=orange,style=filled' | 82 | _shape='shape="diamond",fillcolor="orange",style="filled"' |
214 | 83 | _nFinal = dict() | 83 | _nFinal = dict() |
215 | 84 | 84 | ||
216 | 85 | #print _n1.keys() | ||
217 | 86 | #print _n2.keys() | ||
218 | 87 | |||
219 | 88 | nBoth = set(_n1.keys()).intersection(set(_n2.keys())) | 85 | nBoth = set(_n1.keys()).intersection(set(_n2.keys())) |
220 | 89 | n1Only = set(_n1.keys()).difference(set(_n2.keys())) | 86 | n1Only = set(_n1.keys()).difference(set(_n2.keys())) |
221 | 90 | n2Only = set(_n2.keys()).difference(set(_n1.keys())) | 87 | n2Only = set(_n2.keys()).difference(set(_n1.keys())) |
222 | 91 | 88 | ||
223 | 92 | #print "1" | ||
224 | 93 | #for n in n1Only: | ||
225 | 94 | # print "%s" % (n) | ||
226 | 95 | #print "2" | ||
227 | 96 | #for n in n2Only: | ||
228 | 97 | # print "%s" % (n) | ||
229 | 98 | #print "BOTH" | ||
230 | 99 | #for n in nBoth: | ||
231 | 100 | # print "%s" % (n) | ||
232 | 101 | #sys.exit() | ||
233 | 102 | |||
234 | 103 | nWorking = dict() | 89 | nWorking = dict() |
235 | 104 | nFinal = dict() | 90 | nFinal = dict() |
236 | 105 | 91 | ||
237 | 106 | for node in nBoth: | 92 | for node in nBoth: |
238 | 107 | n = _n1[node] | 93 | n = _n1[node] |
240 | 108 | # if color="red" in both node sets, this pkg is only a Rec | 94 | # if color:red is in both node sets, this pkg is only a Rec |
241 | 109 | # and needs to be red here too. | 95 | # and needs to be red here too. |
242 | 110 | aRec = False | 96 | aRec = False |
243 | 111 | try: | 97 | try: |
244 | @@ -115,11 +101,14 @@ | |||
245 | 115 | except: | 101 | except: |
246 | 116 | pass | 102 | pass |
247 | 117 | try: | 103 | try: |
250 | 118 | if 'color' in _n[node].keys(): | 104 | if 'color' in _n2[node].keys(): |
251 | 119 | if _n1[node][color] == 'red': | 105 | if _n2[node][color] == 'red': |
252 | 120 | aRec = True | 106 | aRec = True |
253 | 107 | else: | ||
254 | 108 | aRec = False | ||
255 | 121 | except: | 109 | except: |
257 | 122 | pass | 110 | aRec = False |
258 | 111 | |||
259 | 123 | if aRec: | 112 | if aRec: |
260 | 124 | n['color'] = 'red' | 113 | n['color'] = 'red' |
261 | 125 | 114 | ||
262 | @@ -134,17 +123,9 @@ | |||
263 | 134 | try: | 123 | try: |
264 | 135 | if 'color' in _n1[node].keys(): | 124 | if 'color' in _n1[node].keys(): |
265 | 136 | if _n1[node][color] == 'red': | 125 | if _n1[node][color] == 'red': |
277 | 137 | aRec = True | 126 | n['color'] = 'red' |
278 | 138 | except: | 127 | except: |
279 | 139 | pass | 128 | pass |
269 | 140 | try: | ||
270 | 141 | if 'color' in _n[node].keys(): | ||
271 | 142 | if _n1[node][color] == 'red': | ||
272 | 143 | aRec = True | ||
273 | 144 | except: | ||
274 | 145 | pass | ||
275 | 146 | if aRec: | ||
276 | 147 | n['color'] = 'red' | ||
280 | 148 | n['shape'] = s1 | 129 | n['shape'] = s1 |
281 | 149 | n['fillcolor'] = c1 | 130 | n['fillcolor'] = c1 |
282 | 150 | n['style'] = 'filled' | 131 | n['style'] = 'filled' |
283 | @@ -152,21 +133,12 @@ | |||
284 | 152 | 133 | ||
285 | 153 | for node in n2Only: | 134 | for node in n2Only: |
286 | 154 | n = _n2[node] | 135 | n = _n2[node] |
287 | 155 | aRec = False | ||
288 | 156 | try: | 136 | try: |
289 | 157 | if 'color' in _n1[node].keys(): | 137 | if 'color' in _n1[node].keys(): |
290 | 158 | if _n1[node][color] == 'red': | 138 | if _n1[node][color] == 'red': |
302 | 159 | aRec = True | 139 | n['color'] = 'red' |
303 | 160 | except: | 140 | except: |
304 | 161 | pass | 141 | pass |
294 | 162 | try: | ||
295 | 163 | if 'color' in _n[node].keys(): | ||
296 | 164 | if _n1[node][color] == 'red': | ||
297 | 165 | aRec = True | ||
298 | 166 | except: | ||
299 | 167 | pass | ||
300 | 168 | if aRec: | ||
301 | 169 | n['color'] = 'red' | ||
305 | 170 | n['shape'] = s2 | 142 | n['shape'] = s2 |
306 | 171 | n['fillcolor'] = c2 | 143 | n['fillcolor'] = c2 |
307 | 172 | n['style'] = 'filled' | 144 | n['style'] = 'filled' |
308 | @@ -196,7 +168,7 @@ | |||
309 | 196 | line = "%s [" % n | 168 | line = "%s [" % n |
310 | 197 | for style in nFinal[n]: | 169 | for style in nFinal[n]: |
311 | 198 | if style == '': continue | 170 | if style == '': continue |
313 | 199 | line += '%s="%s",' %(style,nFinal[n][style]) | 171 | line += '%s="%s",' % (style, nFinal[n][style]) |
314 | 200 | line = line[:len(line)-1] | 172 | line = line[:len(line)-1] |
315 | 201 | line += '];' | 173 | line += '];' |
316 | 202 | print line | 174 | print line |
line 54: exiist -> exist