Merge lp:~knitzsche/dotdepends/bug-1023095 into lp:dotdepends

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
Reviewer Review Type Date Requested Status
Mike Carifio Approve
Review via email: mp+114254@code.launchpad.net
To post a comment you must log in.
lp:~knitzsche/dotdepends/bug-1023095 updated
70. By Kyle Nitzsche

* dotdepends-merge: fixed some blurry logic on setting node borders red
* rest is mostly code cleanup

Revision history for this message
Mike Carifio (carifio) wrote :

line 54: exiist -> exist

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Dotdepends/Dot.py'
--- Dotdepends/Dot.py 2012-07-04 00:40:59 +0000
+++ Dotdepends/Dot.py 2012-07-10 22:00:25 +0000
@@ -92,7 +92,7 @@
92 def get_content(self):92 def get_content(self):
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.
9494
95 Content is the dot file with out the header or footer.95 Content is the dot file without the header or footer.
96 """96 """
97 content = []97 content = []
98 for line in self.dot:98 for line in self.dot:
@@ -106,7 +106,7 @@
106 def get_joins(self):106 def get_joins(self):
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 [[]].
108108
109 Join lines are edgesi between nodes, specifically: lnode -> rnode.109 Join lines are edges between nodes, specifically: lnode -> rnode.
110 There may be a style after the rnode: lnode -> rnode style. Each110 There may be a style after the rnode: lnode -> rnode style. Each
111 top-level list represents a join line. This contains a list containing111 top-level list represents a join line. This contains a list containing
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)]
@@ -130,8 +130,9 @@
130 def get_nodes(self):130 def get_nodes(self):
131 """Returns a dictionary of nodes in the dot file where the key is the131 """Returns a dictionary of nodes in the dot file where the key is the
132 node name and the value is the style, if any, as a string, without the132 node name and the value is the style, if any, as a string, without the
133 closing square brackets.133 enclosing square brackets one finds in a dot file.
134 """134 """
135
135 nodes = dict()136 nodes = dict()
136 node_lines = []137 node_lines = []
137 for line in self.content:138 for line in self.content:
@@ -151,6 +152,7 @@
151 where the key is lnode name and the value is the number of times the152 where the key is lnode name and the value is the number of times the
152 lnode exists as an lnode in the dot file.153 lnode exists as an lnode in the dot file.
153 """154 """
155
154 lnodes = dict()156 lnodes = dict()
155 for join in self.joins:157 for join in self.joins:
156 if len(join) == 0: continue158 if len(join) == 0: continue
@@ -166,6 +168,7 @@
166 where the key is rnode name and the value is the number of times the168 where the key is rnode name and the value is the number of times the
167 rnode exists as an rnode in the dot file.169 rnode exists as an rnode in the dot file.
168 """170 """
171
169 rnodes = dict()172 rnodes = dict()
170 for join in self.joins:173 for join in self.joins:
171 if len(join) == 0: continue174 if len(join) == 0: continue
@@ -177,7 +180,7 @@
177 return rnodes180 return rnodes
178181
179 def get_popular_lnodes(self, popularity):182 def get_popular_lnodes(self, popularity):
180 """Returns a dictionary of lnodes where all lnodes exit as lnodes in183 """Returns a dictionary of lnodes where all lnodes exiist as lnodes in
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.
182 """185 """
183 popular = dict()186 popular = dict()
@@ -215,7 +218,8 @@
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.
216219
217 A family of nodes is a set of nodes that have no lnodes outside of the220 A family of nodes is a set of nodes that have no lnodes outside of the
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
222 outside of the family).
219 """223 """
220224
221 rnodes = self.get_rnodes_for_lnode(node)225 rnodes = self.get_rnodes_for_lnode(node)
@@ -323,8 +327,9 @@
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.
324328
325 Nodes internal to families that are not the family top node are329 Nodes internal to families that are not the family top node are
326 dropped as part of family summariation.330 dropped as part of family summarization.
327 """331 """
332
328 n_nodes = dict()333 n_nodes = dict()
329 for node in self.nodes.keys():334 for node in self.nodes.keys():
330 if node in f_internal_nodes:335 if node in f_internal_nodes:
@@ -338,11 +343,13 @@
338 if not _s.startswith("label="):343 if not _s.startswith("label="):
339 n_styles+= _s + ','344 n_styles+= _s + ','
340 if style.find('fillcolor=blue') >-1:#this is the root node345 if style.find('fillcolor=blue') >-1:#this is the root node
341 style = n_styles + \346 style = n_styles
342"fillcolor=blue,style=filled,shape=%s" % self.shape347 style += "fillcolor=blue,style=filled,shape="
348 style += self.shape
343 else:349 else:
344 style = n_styles + \350 style = n_styles
345"fillcolor=yellow,style=filled,shape=%s" % self.shape351 style += "fillcolor=yellow,style=filled,shape="
352 style += self.shape
346 node = "%s_Family_%d" % (node, len(fams[fam]))353 node = "%s_Family_%d" % (node, len(fams[fam]))
347 if node != fam and node in fams[fam]:354 if node != fam and node in fams[fam]:
348 continue355 continue
349356
=== modified file 'debian/changelog'
--- debian/changelog 2012-07-09 18:43:48 +0000
+++ debian/changelog 2012-07-10 22:00:25 +0000
@@ -1,3 +1,13 @@
1dotdepends (0.3.15kyle1) UNRELEASED; urgency=low
2
3 * redundant 'color="red"' styles in nodes in generated pkg-DETAIL.dot files
4 caused dotdepends-merge on such dot files to incorrected draw some node
5 borders, colorwise. fixes LP: #1023095
6 * dotdepends-merge: fixed some blurry logic on setting node borders red
7 * rest is mostly code cleanup
8
9 -- Kyle Nitzsche <kyle.nitzsche@canonical.com> Tue, 10 Jul 2012 17:53:20 -0400
10
1dotdepends (0.3.15) precise; urgency=low11dotdepends (0.3.15) precise; urgency=low
212
3 * fix recent failures of -d option on dotdepends (disables auto running of13 * fix recent failures of -d option on dotdepends (disables auto running of
414
=== modified file 'debian/rules'
--- debian/rules 2012-06-21 21:33:13 +0000
+++ debian/rules 2012-07-10 22:00:25 +0000
@@ -6,7 +6,6 @@
6override_dh_auto_install:6override_dh_auto_install:
7 python ./setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr --install-layout=deb7 python ./setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr --install-layout=deb
88
9
10 override_dh_auto_clean:9 override_dh_auto_clean:
11 -find . -name '*.py[co]' | xargs rm -f10 -find . -name '*.py[co]' | xargs rm -f
1211
1312
=== modified file 'usr/bin/dotdepends'
--- usr/bin/dotdepends 2012-07-09 18:14:03 +0000
+++ usr/bin/dotdepends 2012-07-10 22:00:25 +0000
@@ -239,8 +239,6 @@
239 ]239 ]
240 if opt.dont_run_dot:240 if opt.dont_run_dot:
241 cmd.append('-d')241 cmd.append('-d')
242 if opt.installed:
243 cmd.append('-i')
244242
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)
246 # a new directory opt.output_dir.244 # a new directory opt.output_dir.
@@ -268,17 +266,14 @@
268 if opt.dont_run_dot:266 if opt.dont_run_dot:
269 cmd.append('-d')267 cmd.append('-d')
270268
271 if opt.installed and opt.mode == 'rdepends':
272 cmd.append('-i')
273
274 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)269 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
275 f2 = p.communicate()270 f2 = p.communicate()
276 # Did the process error?271 # Did the process error?
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')):
278 # Yes, pass the error along273 # Yes, pass the error along
279 print >> sys.stderr, f2[1]274 print >> sys.stderr, f2[1]
280 exit(1)275 sys.exit(1)
281 276
282 f2dot = f2[0].rstrip('.png\n')277 f2dot = f2[0].rstrip('.png\n')
283 if not f2dot.endswith(".dot"):278 if not f2dot.endswith(".dot"):
284 f2dot += ".dot"279 f2dot += ".dot"
@@ -299,7 +294,7 @@
299294
300 _f3 = []295 _f3 = []
301 for line in f3:296 for line in f3:
302 if line.find("->") > -1: 297 if line.find("->") > -1:
303 _f3.append(line)298 _f3.append(line)
304 continue299 continue
305 if line.find("{") > -1:300 if line.find("{") > -1:
@@ -312,7 +307,8 @@
312 _line = line.lstrip()307 _line = line.lstrip()
313 _pkg = _line.split(" ")[0]308 _pkg = _line.split(" ")[0]
314 if _pkg in adds:309 if _pkg in adds:
315 line = line.replace("[", '[color="red",')310 if line.find('color="red"') == -1:
311 line = line.replace("[", '[color="red",')
316 _f3.append(line)312 _f3.append(line)
317313
318 _f = open(f3dot, 'w')314 _f = open(f3dot, 'w')
@@ -321,7 +317,6 @@
321 _f.flush()317 _f.flush()
322 _f.close()318 _f.close()
323319
324
325 if opt.dont_run_dot:320 if opt.dont_run_dot:
326 print f3dot321 print f3dot
327 else:322 else:
@@ -349,7 +344,6 @@
349344
350 sys.exit(0)345 sys.exit(0)
351346
352
353 deps = dict([])347 deps = dict([])
354 recommends = dict([])348 recommends = dict([])
355 onlyRecs = []349 onlyRecs = []
@@ -393,7 +387,7 @@
393 p1 = replacement(k)387 p1 = replacement(k)
394 if p1 == "label": continue388 if p1 == "label": continue
395 p2 = replacement(v)389 p2 = replacement(v)
396 # made joins ('edges')390 # make joins ('edges')
397 if opt.mode == "rdepends":391 if opt.mode == "rdepends":
398 edge = '%s -> %s\n' % (p2,p1)392 edge = '%s -> %s\n' % (p2,p1)
399 elif opt.mode == "depends":393 elif opt.mode == "depends":
400394
=== modified file 'usr/bin/dotdepends-merge'
--- usr/bin/dotdepends-merge 2012-07-09 14:42:21 +0000
+++ usr/bin/dotdepends-merge 2012-07-10 22:00:25 +0000
@@ -79,33 +79,19 @@
79_n1 = addShapes(n1,s1,c1)79_n1 = addShapes(n1,s1,c1)
80_n2 = addShapes(n2,s2,c2)80_n2 = addShapes(n2,s2,c2)
8181
82_shape='shape="diamond",fillcolor=orange,style=filled'82_shape='shape="diamond",fillcolor="orange",style="filled"'
83_nFinal = dict()83_nFinal = dict()
8484
85#print _n1.keys()
86#print _n2.keys()
87
88nBoth = set(_n1.keys()).intersection(set(_n2.keys()))85nBoth = set(_n1.keys()).intersection(set(_n2.keys()))
89n1Only = set(_n1.keys()).difference(set(_n2.keys()))86n1Only = set(_n1.keys()).difference(set(_n2.keys()))
90n2Only = set(_n2.keys()).difference(set(_n1.keys()))87n2Only = set(_n2.keys()).difference(set(_n1.keys()))
9188
92#print "1"
93#for n in n1Only:
94# print "%s" % (n)
95#print "2"
96#for n in n2Only:
97# print "%s" % (n)
98#print "BOTH"
99#for n in nBoth:
100# print "%s" % (n)
101#sys.exit()
102
103nWorking = dict()89nWorking = dict()
104nFinal = dict()90nFinal = dict()
10591
106for node in nBoth:92for node in nBoth:
107 n = _n1[node]93 n = _n1[node]
108 # if color="red" in both node sets, this pkg is only a Rec94 # if color:red is in both node sets, this pkg is only a Rec
109 # and needs to be red here too.95 # and needs to be red here too.
110 aRec = False96 aRec = False
111 try:97 try:
@@ -115,11 +101,14 @@
115 except:101 except:
116 pass102 pass
117 try:103 try:
118 if 'color' in _n[node].keys():104 if 'color' in _n2[node].keys():
119 if _n1[node][color] == 'red':105 if _n2[node][color] == 'red':
120 aRec = True106 aRec = True
107 else:
108 aRec = False
121 except:109 except:
122 pass110 aRec = False
111
123 if aRec:112 if aRec:
124 n['color'] = 'red'113 n['color'] = 'red'
125114
@@ -134,17 +123,9 @@
134 try:123 try:
135 if 'color' in _n1[node].keys():124 if 'color' in _n1[node].keys():
136 if _n1[node][color] == 'red':125 if _n1[node][color] == 'red':
137 aRec = True126 n['color'] = 'red'
138 except:127 except:
139 pass128 pass
140 try:
141 if 'color' in _n[node].keys():
142 if _n1[node][color] == 'red':
143 aRec = True
144 except:
145 pass
146 if aRec:
147 n['color'] = 'red'
148 n['shape'] = s1129 n['shape'] = s1
149 n['fillcolor'] = c1130 n['fillcolor'] = c1
150 n['style'] = 'filled'131 n['style'] = 'filled'
@@ -152,21 +133,12 @@
152133
153for node in n2Only:134for node in n2Only:
154 n = _n2[node]135 n = _n2[node]
155 aRec = False
156 try:136 try:
157 if 'color' in _n1[node].keys():137 if 'color' in _n1[node].keys():
158 if _n1[node][color] == 'red':138 if _n1[node][color] == 'red':
159 aRec = True139 n['color'] = 'red'
160 except:140 except:
161 pass141 pass
162 try:
163 if 'color' in _n[node].keys():
164 if _n1[node][color] == 'red':
165 aRec = True
166 except:
167 pass
168 if aRec:
169 n['color'] = 'red'
170 n['shape'] = s2142 n['shape'] = s2
171 n['fillcolor'] = c2143 n['fillcolor'] = c2
172 n['style'] = 'filled'144 n['style'] = 'filled'
@@ -196,7 +168,7 @@
196 line = "%s [" % n168 line = "%s [" % n
197 for style in nFinal[n]:169 for style in nFinal[n]:
198 if style == '': continue170 if style == '': continue
199 line += '%s="%s",' %(style,nFinal[n][style])171 line += '%s="%s",' % (style, nFinal[n][style])
200 line = line[:len(line)-1]172 line = line[:len(line)-1]
201 line += '];'173 line += '];'
202 print line174 print line

Subscribers

People subscribed via source and target branches

to all changes: