diff options
| author | jvoisin | 2011-08-06 21:44:46 +0200 |
|---|---|---|
| committer | jvoisin | 2011-08-06 21:44:46 +0200 |
| commit | c57b3b6dabff3eebc842f5c3fbd4b6459e6b6794 (patch) | |
| tree | 1329ad055a21e8a4876b15a85b34ae75beca1562 /lib | |
| parent | f272bb5d65e2daa7ca49dd52f65aab54f793bc16 (diff) | |
Portability improvement for the archive module
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/archive.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/archive.py b/lib/archive.py index fb15705..ee05d9e 100644 --- a/lib/archive.py +++ b/lib/archive.py | |||
| @@ -129,8 +129,7 @@ harmless format' % item.filename) | |||
| 129 | Is shiping a patched version of zipfile.py a good idea ? | 129 | Is shiping a patched version of zipfile.py a good idea ? |
| 130 | ''' | 130 | ''' |
| 131 | zipin = zipfile.ZipFile(self.filename, 'r') | 131 | zipin = zipfile.ZipFile(self.filename, 'r') |
| 132 | zipout = zipfile.ZipFile(self.output, 'w', | 132 | zipout = zipfile.ZipFile(self.output, 'w', allowZip64=True) |
| 133 | allowZip64=True) | ||
| 134 | for item in zipin.infolist(): | 133 | for item in zipin.infolist(): |
| 135 | zipin.extract(item, self.tempdir) | 134 | zipin.extract(item, self.tempdir) |
| 136 | name = os.path.join(self.tempdir, item.filename) | 135 | name = os.path.join(self.tempdir, item.filename) |
| @@ -146,9 +145,10 @@ harmless format' % item.filename) | |||
| 146 | self.filename)) | 145 | self.filename)) |
| 147 | zipout.write(name, item.filename) | 146 | zipout.write(name, item.filename) |
| 148 | except: | 147 | except: |
| 149 | logging.info('%s\' fileformat is not supported' % | 148 | logging.info('%s\'s format is not supported or harmless' % |
| 150 | item.filename) | 149 | item.filename) |
| 151 | if self.add2archive: | 150 | _, ext = os.path.splitext(name) |
| 151 | if self.add2archive or ext in parser.NOMETA: | ||
| 152 | zipout.write(name, item.filename) | 152 | zipout.write(name, item.filename) |
| 153 | mat.secure_remove(name) | 153 | mat.secure_remove(name) |
| 154 | zipout.comment = '' | 154 | zipout.comment = '' |
| @@ -190,9 +190,10 @@ class TarStripper(GenericArchiveStripper): | |||
| 190 | cfile.remove_all_ugly() | 190 | cfile.remove_all_ugly() |
| 191 | tarout.add(name, item.name, filter=self._remove) | 191 | tarout.add(name, item.name, filter=self._remove) |
| 192 | except: | 192 | except: |
| 193 | logging.info('%s\' format is not supported' % | 193 | logging.info('%s\' format is not supported or harmless' % |
| 194 | item.name) | 194 | item.name) |
| 195 | if self.add2archive: | 195 | _, ext = os.path.splitext(name) |
| 196 | if self.add2archive or ext in parser.NOMETA: | ||
| 196 | tarout.add(name, item.name, filter=self._remove) | 197 | tarout.add(name, item.name, filter=self._remove) |
| 197 | mat.secure_remove(name) | 198 | mat.secure_remove(name) |
| 198 | tarin.close() | 199 | tarin.close() |
| @@ -228,16 +229,15 @@ class TarStripper(GenericArchiveStripper): | |||
| 228 | tarin.extract(item, self.tempdir) | 229 | tarin.extract(item, self.tempdir) |
| 229 | name = os.path.join(self.tempdir, item.name) | 230 | name = os.path.join(self.tempdir, item.name) |
| 230 | if item.type is '0': # is item a regular file ? | 231 | if item.type is '0': # is item a regular file ? |
| 231 | #no backup file | ||
| 232 | try: | 232 | try: |
| 233 | class_file = mat.create_class_file(name, | 233 | class_file = mat.create_class_file(name, |
| 234 | False, self.add2archive) | 234 | False, self.add2archive) #no backup file |
| 235 | if not class_file.is_clean(): | 235 | if not class_file.is_clean(): |
| 236 | tarin.close() | 236 | tarin.close() |
| 237 | return False | 237 | return False |
| 238 | except: | 238 | except: |
| 239 | #best solution I have found | 239 | logging.error('%s\'s foramt is not supported or harmless' % |
| 240 | logging.error('%s is not supported' % item.filename) | 240 | item.filename) |
| 241 | _, ext = os.path.splitext(name) | 241 | _, ext = os.path.splitext(name) |
| 242 | if ext not in parser.NOMETA: | 242 | if ext not in parser.NOMETA: |
| 243 | tarin.close() | 243 | tarin.close() |
