summaryrefslogtreecommitdiff
path: root/mat.py
diff options
context:
space:
mode:
authorjvoisin2011-06-16 19:43:25 +0200
committerjvoisin2011-06-16 19:43:25 +0200
commit42ae7703911f69e3d830c7dd780167e2d6c54eeb (patch)
tree348ea4f6baacb3925a6d4ecfcf02bfb128e09b5c /mat.py
parent55bf18b52edb2496380378f6f952d4de82df2733 (diff)
Complete rewrite of the is_clean() method
preliminary work on the _remove() method, which apparently does not want to work.
Diffstat (limited to 'mat.py')
-rwxr-xr-xmat.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/mat.py b/mat.py
index cec4129..f59bdce 100755
--- a/mat.py
+++ b/mat.py
@@ -5,6 +5,7 @@
5''' 5'''
6 6
7import hachoir_core.error 7import hachoir_core.error
8import hachoir_core.field
8import hachoir_core.cmd_line 9import hachoir_core.cmd_line
9import hachoir_parser 10import hachoir_parser
10import hachoir_metadata 11import hachoir_metadata
@@ -21,7 +22,6 @@ __author__ = "jvoisin"
21class file(): 22class file():
22 def __init__(self, realname, filename, parser, editor): 23 def __init__(self, realname, filename, parser, editor):
23 self.meta = {} 24 self.meta = {}
24 self.clean = False
25 self.filename = filename 25 self.filename = filename
26 self.realname = realname 26 self.realname = realname
27 self.parser = parser 27 self.parser = parser
@@ -50,9 +50,12 @@ class file():
50 50
51 def is_clean(self): 51 def is_clean(self):
52 ''' 52 '''
53 Return true if the file is clean from any compromizing meta 53 Check if the file is clean from harmful metadatas
54 ''' 54 '''
55 return self.clean 55 for key, field in self.meta.iteritems():
56 if self._should_remove(key):
57 return False
58 return True
56 59
57 def remove_all(self): 60 def remove_all(self):
58 ''' 61 '''
@@ -60,15 +63,15 @@ class file():
60 ''' 63 '''
61 for key, field in self.meta.iteritems(): 64 for key, field in self.meta.iteritems():
62 if self._should_remove(key): 65 if self._should_remove(key):
63 print "BLEH" #DEBUG 66 self._remove(key)
64 #_remove(self, key) 67 hachoir_core.field.writeIntoFile(self.editor, self.filename + "cleaned")
65 #self.clean = True 68
66 69
67 def _remove(self, field): 70 def _remove(self, key):
68 ''' 71 '''
69 Remove the given file 72 Remove the given field
70 ''' 73 '''
71 del self.editor[field] 74 del self.editor[key]
72 75
73 76
74 def get_meta(self): 77 def get_meta(self):
@@ -79,7 +82,7 @@ class file():
79 82
80 def get_harmful(self): 83 def get_harmful(self):
81 ''' 84 '''
82 return a dict with all the harmfull meta of the file 85 return a dict with all the harmful meta of the file
83 ''' 86 '''
84 harmful = {} 87 harmful = {}
85 for key, value in self.meta.iteritems(): 88 for key, value in self.meta.iteritems():