diff options
| -rw-r--r-- | MAT/exiftool.py | 2 | ||||
| -rw-r--r-- | MAT/mutagenstripper.py | 3 | ||||
| -rw-r--r-- | MAT/parser.py | 12 |
3 files changed, 14 insertions, 3 deletions
diff --git a/MAT/exiftool.py b/MAT/exiftool.py index 1cae352..d2d177c 100644 --- a/MAT/exiftool.py +++ b/MAT/exiftool.py | |||
| @@ -32,7 +32,7 @@ class ExiftoolStripper(parser.GenericParser): | |||
| 32 | ''' | 32 | ''' |
| 33 | try: | 33 | try: |
| 34 | if self.backup: | 34 | if self.backup: |
| 35 | shutil.copy2(self.filename, self.filename + '.bak') | 35 | self.create_backup_copy() |
| 36 | # Note: '-All=' must be followed by a known exiftool option. | 36 | # Note: '-All=' must be followed by a known exiftool option. |
| 37 | process = subprocess.Popen( ['exiftool', '-m', '-all=', | 37 | process = subprocess.Popen( ['exiftool', '-m', '-all=', |
| 38 | '-adobe=', '-overwrite_original', self.filename ], | 38 | '-adobe=', '-overwrite_original', self.filename ], |
diff --git a/MAT/mutagenstripper.py b/MAT/mutagenstripper.py index 34f5705..9d82a30 100644 --- a/MAT/mutagenstripper.py +++ b/MAT/mutagenstripper.py | |||
| @@ -15,8 +15,7 @@ class MutagenStripper(parser.GenericParser): | |||
| 15 | 15 | ||
| 16 | def remove_all(self): | 16 | def remove_all(self): |
| 17 | if self.backup: | 17 | if self.backup: |
| 18 | shutil.copy2(self.filename, self.filename + '.bak') | 18 | self.create_backup_copy() |
| 19 | |||
| 20 | self.mfile.delete() | 19 | self.mfile.delete() |
| 21 | self.mfile.save() | 20 | self.mfile.save() |
| 22 | return True | 21 | return True |
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. |
