Browse Source

use setdefault instead of a try/except block..

break out some code so it's easier to debug..

[git-p4: depot-paths = "//depot/": change = 1747]
main
John-Mark Gurney 10 years ago
parent
commit
405ddf8990
1 changed files with 4 additions and 7 deletions
  1. +4
    -7
      ZipStorage.py

+ 4
- 7
ZipStorage.py View File

@@ -46,11 +46,7 @@ def inserthierdict(d, name, obj, sep):
dname = name[:i]
rname = name[i + 1:]
# remaining path components
try:
inserthierdict(d[dname], rname, obj, sep)
except KeyError:
d[dname] = {}
inserthierdict(d[dname], rname, obj, sep)
inserthierdict(d.setdefaul(dname, {}), rname, obj, sep)

def buildNameHier(names, objs, sep):
ret = {}
@@ -308,8 +304,9 @@ class ZipObject(FSObject, StorageFolder):
cnt = newsum
self.sep = cursep

hier = buildNameHier(nl, [ ZIWrap(x) for x in
self.zip.infolist() ], cursep)
il = self.zip.infolist()

hier = buildNameHier(nl, [ ZIWrap(x) for x in il ], cursep)

return hier



Loading…
Cancel
Save