diff options
| author | jvoisin | 2012-02-06 02:05:05 +0100 |
|---|---|---|
| committer | jvoisin | 2012-02-06 02:05:05 +0100 |
| commit | 2cba152e7c00ff2c422d5e1c911f17ea07f346ed (patch) | |
| tree | e83a362b8f49f72b0457af7fd566ea37f9815b14 /lib/archive.py | |
| parent | c71999c4f789beb8812f9570926f894ac9f1938e (diff) | |
Merge the two processing mode into a unique one
Diffstat (limited to 'lib/archive.py')
| -rw-r--r-- | lib/archive.py | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/lib/archive.py b/lib/archive.py index 9993102..a749b29 100644 --- a/lib/archive.py +++ b/lib/archive.py | |||
| @@ -36,22 +36,9 @@ class GenericArchiveStripper(parser.GenericParser): | |||
| 36 | shutil.rmtree(self.tempdir) | 36 | shutil.rmtree(self.tempdir) |
| 37 | 37 | ||
| 38 | def remove_all(self): | 38 | def remove_all(self): |
| 39 | ''' | 39 | return self._remove_all() |
| 40 | Call _remove_all() with in argument : "normal" | ||
| 41 | ''' | ||
| 42 | return self._remove_all('normal') | ||
| 43 | 40 | ||
| 44 | def remove_all_strict(self): | 41 | def _remove_all(self): |
| 45 | ''' | ||
| 46 | call remove_all() with in argument : "strict" | ||
| 47 | ''' | ||
| 48 | return self._remove_all('strict') | ||
| 49 | |||
| 50 | def _remove_all(self, method): | ||
| 51 | ''' | ||
| 52 | Remove all meta, normal way if method is "normal", | ||
| 53 | else, use the strict way (with possible data loss) | ||
| 54 | ''' | ||
| 55 | raise NotImplementedError | 42 | raise NotImplementedError |
| 56 | 43 | ||
| 57 | 44 | ||
| @@ -127,7 +114,7 @@ harmless format' % item.filename) | |||
| 127 | zipin.close() | 114 | zipin.close() |
| 128 | return metadata | 115 | return metadata |
| 129 | 116 | ||
| 130 | def _remove_all(self, method): | 117 | def _remove_all(self): |
| 131 | ''' | 118 | ''' |
| 132 | So far, the zipfile module does not allow to write a ZipInfo | 119 | So far, the zipfile module does not allow to write a ZipInfo |
| 133 | object into a zipfile (and it's a shame !) : so data added | 120 | object into a zipfile (and it's a shame !) : so data added |
| @@ -143,10 +130,7 @@ harmless format' % item.filename) | |||
| 143 | try: | 130 | try: |
| 144 | cfile = mat.create_class_file(name, False, | 131 | cfile = mat.create_class_file(name, False, |
| 145 | self.add2archive) | 132 | self.add2archive) |
| 146 | if method is 'normal': | 133 | cfile.remove_all() |
| 147 | cfile.remove_all() | ||
| 148 | else: | ||
| 149 | cfile.remove_all_strict() | ||
| 150 | logging.debug('Processing %s from %s' % (item.filename, | 134 | logging.debug('Processing %s from %s' % (item.filename, |
| 151 | self.filename)) | 135 | self.filename)) |
| 152 | zipout.write(name, item.filename) | 136 | zipout.write(name, item.filename) |
| @@ -179,7 +163,7 @@ class TarStripper(GenericArchiveStripper): | |||
| 179 | current_file.gname = '' | 163 | current_file.gname = '' |
| 180 | return current_file | 164 | return current_file |
| 181 | 165 | ||
| 182 | def _remove_all(self, method): | 166 | def _remove_all(self): |
| 183 | tarin = tarfile.open(self.filename, 'r' + self.compression) | 167 | tarin = tarfile.open(self.filename, 'r' + self.compression) |
| 184 | tarout = tarfile.open(self.output, 'w' + self.compression) | 168 | tarout = tarfile.open(self.output, 'w' + self.compression) |
| 185 | for item in tarin.getmembers(): | 169 | for item in tarin.getmembers(): |
| @@ -190,10 +174,7 @@ class TarStripper(GenericArchiveStripper): | |||
| 190 | try: | 174 | try: |
| 191 | cfile = mat.create_class_file(name, False, | 175 | cfile = mat.create_class_file(name, False, |
| 192 | self.add2archive) | 176 | self.add2archive) |
| 193 | if method is 'normal': | 177 | cfile.remove_all() |
| 194 | cfile.remove_all() | ||
| 195 | else: | ||
| 196 | cfile.remove_all_strict() | ||
| 197 | tarout.add(name, item.name, filter=self._remove) | 178 | tarout.add(name, item.name, filter=self._remove) |
| 198 | except: | 179 | except: |
| 199 | logging.info('%s\' format is not supported or harmless' % | 180 | logging.info('%s\' format is not supported or harmless' % |
