Kaydet (Commit) 7c77a44c authored tarafından Tor Lillqvist's avatar Tor Lillqvist Kaydeden (comit) Tomaž Vajngerl

Beware of modifying a list being iterated

Change-Id: Ib9cf1a47eb20bd28d954ddcded89f67cf6865f1c
üst ebd86807
...@@ -54,18 +54,26 @@ if __name__ == '__main__': ...@@ -54,18 +54,26 @@ if __name__ == '__main__':
tree = ET.parse(sys.argv[1]) tree = ET.parse(sys.argv[1])
root = tree.getroot() root = tree.getroot()
saved = 0
total = 0 total = 0
for child in root: for child in root:
section = child.attrib['{http://openoffice.org/2001/registry}name'] total += len(ET.tostring(child))
package = child.attrib['{http://openoffice.org/2001/registry}package']
size = len(ET.tostring(child)); saved = 0
total = total + size restarted = True
key = '%s/%s' % (package, section)
if key in main_xcd_discard: while restarted:
root.remove(child) restarted = False
print 'removed %s - saving %d' % (key, size) for child in root:
saved = saved + size section = child.attrib['{http://openoffice.org/2001/registry}name']
package = child.attrib['{http://openoffice.org/2001/registry}package']
size = len(ET.tostring(child));
key = '%s/%s' % (package, section)
if key in main_xcd_discard:
root.remove(child)
print 'removed %s - saving %d' % (key, size)
saved = saved + size
restarted = True
break
print "saved %d of %d bytes: %2.f%%" % (saved, total, saved*100.0/total) print "saved %d of %d bytes: %2.f%%" % (saved, total, saved*100.0/total)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment