diff options
| author | jvoisin | 2012-01-22 01:32:09 +0100 |
|---|---|---|
| committer | jvoisin | 2012-01-22 01:32:09 +0100 |
| commit | 3700a9c4b138cab1d1dac8ab1aad02acc18d798b (patch) | |
| tree | a13346df2f09dca582a95470ad1254e8752382f6 /mat | |
| parent | e96e5b8ac44095668198e3e6797a3f77d9fb4634 (diff) | |
Revert "Preliminary handling of ctime/mtime reset"
This reverts commit e96e5b8ac44095668198e3e6797a3f77d9fb4634.
Everything is already in a branch
Diffstat (limited to 'mat')
| -rw-r--r-- | mat/archive.py | 9 | ||||
| -rw-r--r-- | mat/audio.py | 2 | ||||
| -rw-r--r-- | mat/exiftool.py | 1 | ||||
| -rw-r--r-- | mat/misc.py | 1 | ||||
| -rw-r--r-- | mat/office.py | 4 | ||||
| -rw-r--r-- | mat/parser.py | 31 |
6 files changed, 2 insertions, 46 deletions
diff --git a/mat/archive.py b/mat/archive.py index 84ef10a..9993102 100644 --- a/mat/archive.py +++ b/mat/archive.py | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | import zipfile | 5 | import zipfile |
| 6 | import shutil | 6 | import shutil |
| 7 | import os | 7 | import os |
| 8 | import time | ||
| 9 | import logging | 8 | import logging |
| 10 | import tempfile | 9 | import tempfile |
| 11 | 10 | ||
| @@ -13,10 +12,6 @@ import parser | |||
| 13 | import mat | 12 | import mat |
| 14 | from tarfile import tarfile | 13 | from tarfile import tarfile |
| 15 | 14 | ||
| 16 | #Zip fileformat does not handle dates | ||
| 17 | #prior to 1980 | ||
| 18 | ZIP_TIME = 315529200 #1jan1980 | ||
| 19 | |||
| 20 | 15 | ||
| 21 | class GenericArchiveStripper(parser.GenericParser): | 16 | class GenericArchiveStripper(parser.GenericParser): |
| 22 | ''' | 17 | ''' |
| @@ -166,9 +161,6 @@ harmless format' % item.filename) | |||
| 166 | zipout.close() | 161 | zipout.close() |
| 167 | logging.info('%s treated' % self.filename) | 162 | logging.info('%s treated' % self.filename) |
| 168 | self.do_backup() | 163 | self.do_backup() |
| 169 | #time = 1980 | ||
| 170 | # TODO | ||
| 171 | #self.set_time(time) | ||
| 172 | return True | 164 | return True |
| 173 | 165 | ||
| 174 | 166 | ||
| @@ -212,7 +204,6 @@ class TarStripper(GenericArchiveStripper): | |||
| 212 | tarin.close() | 204 | tarin.close() |
| 213 | tarout.close() | 205 | tarout.close() |
| 214 | self.do_backup() | 206 | self.do_backup() |
| 215 | self.set_time(parser.EPOCH) | ||
| 216 | return True | 207 | return True |
| 217 | 208 | ||
| 218 | def is_file_clean(self, current_file): | 209 | def is_file_clean(self, current_file): |
diff --git a/mat/audio.py b/mat/audio.py index 4682db1..ed849ee 100644 --- a/mat/audio.py +++ b/mat/audio.py | |||
| @@ -35,7 +35,6 @@ class OggStripper(parser.GenericParser): | |||
| 35 | mfile = OggVorbis(self.filename) | 35 | mfile = OggVorbis(self.filename) |
| 36 | mfile.delete() | 36 | mfile.delete() |
| 37 | mfile.save() | 37 | mfile.save() |
| 38 | self.set_time(parser.EPOCH) | ||
| 39 | return True | 38 | return True |
| 40 | 39 | ||
| 41 | def is_clean(self): | 40 | def is_clean(self): |
| @@ -75,7 +74,6 @@ class FlacStripper(parser.GenericParser): | |||
| 75 | mfile.delete() | 74 | mfile.delete() |
| 76 | mfile.clear_pictures() | 75 | mfile.clear_pictures() |
| 77 | mfile.save() | 76 | mfile.save() |
| 78 | self.set_time(parser.EPOCH) | ||
| 79 | return True | 77 | return True |
| 80 | 78 | ||
| 81 | def is_clean(self): | 79 | def is_clean(self): |
diff --git a/mat/exiftool.py b/mat/exiftool.py index 47e7dfc..758a094 100644 --- a/mat/exiftool.py +++ b/mat/exiftool.py | |||
| @@ -43,7 +43,6 @@ class ExiftoolStripper(parser.GenericParser): | |||
| 43 | [ 'exiftool', '-m', '-All=', '-overwrite_original', self.filename ], | 43 | [ 'exiftool', '-m', '-All=', '-overwrite_original', self.filename ], |
| 44 | stdout=open('/dev/null')) | 44 | stdout=open('/dev/null')) |
| 45 | process.wait() | 45 | process.wait() |
| 46 | self.set_time(parser.EPOCH) | ||
| 47 | return True | 46 | return True |
| 48 | except: | 47 | except: |
| 49 | return False | 48 | return False |
diff --git a/mat/misc.py b/mat/misc.py index 80ccc79..d084861 100644 --- a/mat/misc.py +++ b/mat/misc.py | |||
| @@ -60,5 +60,4 @@ class TorrentStripper(parser.GenericParser): | |||
| 60 | with open(self.output, 'w') as f: # encode the decoded torrent | 60 | with open(self.output, 'w') as f: # encode the decoded torrent |
| 61 | f.write(bencode.bencode(decoded)) # and write it in self.output | 61 | f.write(bencode.bencode(decoded)) # and write it in self.output |
| 62 | self.do_backup() | 62 | self.do_backup() |
| 63 | self.set_time(parser.EPOCH) | ||
| 64 | return True | 63 | return True |
diff --git a/mat/office.py b/mat/office.py index 5ff9a83..e1d738e 100644 --- a/mat/office.py +++ b/mat/office.py | |||
| @@ -100,7 +100,6 @@ class OpenDocumentStripper(archive.GenericArchiveStripper): | |||
| 100 | zipin.close() | 100 | zipin.close() |
| 101 | zipout.close() | 101 | zipout.close() |
| 102 | self.do_backup() | 102 | self.do_backup() |
| 103 | self.set_time(archive.ZIP_TIME) | ||
| 104 | return True | 103 | return True |
| 105 | 104 | ||
| 106 | def is_clean(self): | 105 | def is_clean(self): |
| @@ -214,8 +213,6 @@ class PdfStripper(parser.GenericParser): | |||
| 214 | if processed is False: | 213 | if processed is False: |
| 215 | logging.error('Please install either pdfrw, or exiftool to\ | 214 | logging.error('Please install either pdfrw, or exiftool to\ |
| 216 | fully handle PDF files') | 215 | fully handle PDF files') |
| 217 | |||
| 218 | self.set_time(parser.EPOCH) | ||
| 219 | return processed | 216 | return processed |
| 220 | 217 | ||
| 221 | def get_meta(self): | 218 | def get_meta(self): |
| @@ -277,7 +274,6 @@ class OpenXmlStripper(archive.GenericArchiveStripper): | |||
| 277 | zipin.close() | 274 | zipin.close() |
| 278 | zipout.close() | 275 | zipout.close() |
| 279 | self.do_backup() | 276 | self.do_backup() |
| 280 | self.set_time(archive.ZIP_TIME) | ||
| 281 | return True | 277 | return True |
| 282 | 278 | ||
| 283 | def is_clean(self): | 279 | def is_clean(self): |
diff --git a/mat/parser.py b/mat/parser.py index 0c6f0ee..6dc5d0b 100644 --- a/mat/parser.py +++ b/mat/parser.py | |||
| @@ -6,18 +6,15 @@ import hachoir_core | |||
| 6 | import hachoir_editor | 6 | import hachoir_editor |
| 7 | 7 | ||
| 8 | import os | 8 | import os |
| 9 | import time | ||
| 10 | import sys | ||
| 11 | 9 | ||
| 12 | import mat | 10 | import mat |
| 13 | 11 | ||
| 14 | NOMETA = ('.bmp', '.rdf', '.txt', '.xml', '.rels') | 12 | NOMETA = ('.bmp', '.rdf', '.txt', '.xml', '.rels') |
| 15 | EPOCH = 0 | ||
| 16 | #bmp : image | 13 | #bmp : image |
| 17 | #rdf : text | 14 | #rdf : text |
| 18 | #txt : plain text | 15 | #txt : plain text |
| 19 | #xml : formated text | 16 | #xml : formated text |
| 20 | #rels : openxml formated text | 17 | #rels : openxml foramted text |
| 21 | 18 | ||
| 22 | 19 | ||
| 23 | FIELD = object() | 20 | FIELD = object() |
| @@ -58,14 +55,7 @@ class GenericParser(object): | |||
| 58 | if remove is FIELD: | 55 | if remove is FIELD: |
| 59 | if not self._is_clean(field): | 56 | if not self._is_clean(field): |
| 60 | return False | 57 | return False |
| 61 | 58 | return True | |
| 62 | def is_time_clean(self): | ||
| 63 | ''' | ||
| 64 | Check if the atime and the mtime | ||
| 65 | of self.filename is Epoch | ||
| 66 | ''' | ||
| 67 | stat = os.stat(self.filename) | ||
| 68 | return stat.st_atime == 0 and stat.st_mtime == 0 | ||
| 69 | 59 | ||
| 70 | def remove_all(self): | 60 | def remove_all(self): |
| 71 | ''' | 61 | ''' |
| @@ -74,7 +64,6 @@ class GenericParser(object): | |||
| 74 | state = self._remove_all(self.editor) | 64 | state = self._remove_all(self.editor) |
| 75 | hachoir_core.field.writeIntoFile(self.editor, self.output) | 65 | hachoir_core.field.writeIntoFile(self.editor, self.output) |
| 76 | self.do_backup() | 66 | self.do_backup() |
| 77 | self.set_time(EPOCH) | ||
| 78 | return state | 67 | return state |
| 79 | 68 | ||
| 80 | def _remove_all(self, fieldset): | 69 | def _remove_all(self, fieldset): |
| @@ -139,19 +128,3 @@ class GenericParser(object): | |||
| 139 | if self.backup is False: | 128 | if self.backup is False: |
| 140 | mat.secure_remove(self.filename) | 129 | mat.secure_remove(self.filename) |
| 141 | os.rename(self.output, self.filename) | 130 | os.rename(self.output, self.filename) |
| 142 | |||
| 143 | def set_time(self, time): | ||
| 144 | ''' | ||
| 145 | Set the ctime of the file to $time | ||
| 146 | ''' | ||
| 147 | filename = '' | ||
| 148 | if self.backup is True: | ||
| 149 | filename = self.output | ||
| 150 | else: | ||
| 151 | filename = self.filename | ||
| 152 | |||
| 153 | try: | ||
| 154 | os.utime(filename, (time, time)) | ||
| 155 | except: | ||
| 156 | print "Unable to set %s's date to %s" % (filename, time) | ||
| 157 | sys.exit(1) | ||
