[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/ Adjusted TarballImportContext to work with Python 2.6's tarfile module.
Hanno Schlichting
plone at hannosch.info
Sat Jan 17 15:58:44 EST 2009
Log message for revision 94811:
Adjusted TarballImportContext to work with Python 2.6's tarfile module.
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/trunk/Products/GenericSetup/context.py
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2009-01-17 20:41:54 UTC (rev 94810)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2009-01-17 20:58:43 UTC (rev 94811)
@@ -4,6 +4,8 @@
GenericSetup 1.5.0 (unreleased)
-------------------------------
+- Adjusted TarballImportContext to work with Python 2.6's tarfile module.
+
- Cleaned up / normalized imports:
o Don't import from Globals; instead, use real locations.
Modified: Products.GenericSetup/trunk/Products/GenericSetup/context.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/context.py 2009-01-17 20:41:54 UTC (rev 94810)
+++ Products.GenericSetup/trunk/Products/GenericSetup/context.py 2009-01-17 20:58:43 UTC (rev 94811)
@@ -377,12 +377,17 @@
pfx_len = len(path)
names = []
- for name in self._archive.getnames():
+ for info in self._archive.getmembers():
+ name = info.name
if name == path or not name.startswith(path):
continue
name = name[pfx_len:]
- if '/' in name or name in skip:
+ if name in skip:
continue
+ # In earlier Python versions directories would always have a
+ # slash in their name.
+ if '/' in name or info.isdir():
+ continue
if [s for s in skip_suffixes if name.endswith(s)]:
continue
names.append(name)
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py 2009-01-17 20:41:54 UTC (rev 94810)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py 2009-01-17 20:58:43 UTC (rev 94811)
@@ -658,6 +658,8 @@
site, tool, ctx = self._makeOne( { FILENAME: printable } )
+ # Beware! The test setup actually does add two entries into the
+ # context. One is a folder and should be filtered out.
self.assertEqual( len( ctx.listDirectory( None ) ), 1 )
self.failUnless( FILENAME in ctx.listDirectory( None ) )
More information about the Checkins
mailing list