[Libreoffice-commits] core.git: Branch 'feature/droid_calcimpress3' - android/mobile-config.py

Tor Lillqvist tml at collabora.com
Mon Oct 27 01:33:46 PDT 2014


 android/mobile-config.py |   28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

New commits:
commit 32b8d6734388e9e67db5ed76277874f9aaf9c740
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Oct 27 10:19:59 2014 +0200

    Beware of modifying a list being iterated
    
    Change-Id: Ib9cf1a47eb20bd28d954ddcded89f67cf6865f1c

diff --git a/android/mobile-config.py b/android/mobile-config.py
index ff2fd53..cdf0afc 100755
--- a/android/mobile-config.py
+++ b/android/mobile-config.py
@@ -54,18 +54,26 @@ if __name__ == '__main__':
     tree = ET.parse(sys.argv[1])
     root = tree.getroot()
 
-    saved = 0
     total = 0
     for child in root:
-        section = child.attrib['{http://openoffice.org/2001/registry}name']
-        package = child.attrib['{http://openoffice.org/2001/registry}package']
-        size = len(ET.tostring(child));
-        total = total + size
-        key = '%s/%s' % (package, section)
-        if key in main_xcd_discard:
-            root.remove(child)
-            print 'removed %s - saving %d' % (key, size)
-            saved = saved + size
+        total += len(ET.tostring(child))
+
+    saved = 0
+    restarted = True
+
+    while restarted:
+        restarted = False
+        for child in root:
+            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)
 


More information about the Libreoffice-commits mailing list