summaryrefslogtreecommitdiff
path: root/MAT
diff options
context:
space:
mode:
authorjvoisin2013-07-17 12:58:20 +0200
committerjvoisin2013-07-17 12:58:20 +0200
commitaec34378a69f4e38c39c703a6baa6d1f09deed5f (patch)
treebcf35b2a427e6ffc3d78e6420fd770adb1bec608 /MAT
parent82421f5519ea0e409c5249026ca81fa9bd2b48fd (diff)
Minor refactoring
Diffstat (limited to 'MAT')
-rw-r--r--MAT/exiftool.py2
-rw-r--r--MAT/mutagenstripper.py3
-rw-r--r--MAT/parser.py12
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
8import os 8import os
9import tempfile 9import tempfile
10import shutil
10 11
11import mat 12import 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.