diff options
Diffstat (limited to 'MAT/parser.py')
| -rw-r--r-- | MAT/parser.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/MAT/parser.py b/MAT/parser.py index 2dda074..e956164 100644 --- a/MAT/parser.py +++ b/MAT/parser.py | |||
| @@ -7,6 +7,7 @@ import hachoir_editor | |||
| 7 | 7 | ||
| 8 | import os | 8 | import os |
| 9 | import tempfile | 9 | import tempfile |
| 10 | import shutil | ||
| 10 | 11 | ||
| 11 | import mat | 12 | import mat |
| 12 | 13 | ||
| @@ -38,6 +39,12 @@ class GenericParser(object): | |||
| 38 | _, output = tempfile.mkstemp() | 39 | _, output = tempfile.mkstemp() |
| 39 | self.output = hachoir_core.cmd_line.unicodeFilename(output) | 40 | self.output = hachoir_core.cmd_line.unicodeFilename(output) |
| 40 | 41 | ||
| 42 | def __del__(self): | ||
| 43 | ''' Remove tempfile if it was not used | ||
| 44 | ''' | ||
| 45 | if os.path.exists(self.output): | ||
| 46 | mat.secure_remove(self.output) | ||
| 47 | |||
| 41 | def is_clean(self): | 48 | def is_clean(self): |
| 42 | ''' | 49 | ''' |
| 43 | Check if the file is clean from harmful metadatas | 50 | Check if the file is clean from harmful metadatas |
| @@ -116,6 +123,11 @@ class GenericParser(object): | |||
| 116 | ''' | 123 | ''' |
| 117 | raise NotImplementedError | 124 | raise NotImplementedError |
| 118 | 125 | ||
| 126 | def create_backup_copy(self): | ||
| 127 | ''' Create a backup copy | ||
| 128 | ''' | ||
| 129 | shutil.copy2(self.filename, self.filename + '.bak') | ||
| 130 | |||
| 119 | def do_backup(self): | 131 | def do_backup(self): |
| 120 | ''' | 132 | ''' |
| 121 | Keep a backup of the file if asked. | 133 | Keep a backup of the file if asked. |
