Commits

Yuya Nishihara  committed 6a593b3

extract func to list up extensions in zipfile

  • Participants
  • Parent commits 6c07f04

Comments (0)

Files changed (1)

File hgext/fixfrozenexts.py

 def _libpath():
     return os.path.join(os.path.dirname(sys.executable), 'library.zip')
 
+def _listzippedexts(zf):
+    exts = {}
+    for e in zf.namelist():
+        if not e.startswith('hgext/'):
+            continue
+        if e.endswith('.pyo'):
+            name = e[6:].rsplit('.', 1)[0]
+            path = e
+            exts[name] = path
+        else:
+            pass  # FIXME
+    return exts
+
 def _disabledpaths(orig, strip_init=False):
-    exts = {}
     zf = zipfile.ZipFile(_libpath())
     try:
-        for e in zf.namelist():
-            if not e.startswith('hgext/'):
-                continue
-            if e.endswith('.pyo'):
-                name = e[6:].rsplit('.', 1)[0]
-                path = e
-                exts[name] = path
-            else:
-                pass  # FIXME
-        return exts
+        return _listzippedexts(zf)
     finally:
         zf.close()