summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2011-08-06 22:43:17 +0200
committerjvoisin2011-08-06 22:43:17 +0200
commit008cb53a98681ed1be8a1d2f767ecf50fba585bb (patch)
tree99da4c28ec2a0ddbec48014e003d95047d111945
parentc57b3b6dabff3eebc842f5c3fbd4b6459e6b6794 (diff)
Cleanup and more pylint conformity
-rwxr-xr-xcli.py2
-rw-r--r--gui.py6
-rw-r--r--lib/archive.py4
-rw-r--r--lib/audio.py38
-rw-r--r--lib/mat.py7
-rw-r--r--lib/misc.py4
-rw-r--r--lib/office.py6
-rw-r--r--lib/parser.py1
8 files changed, 19 insertions, 49 deletions
diff --git a/cli.py b/cli.py
index a540258..7c4c399 100755
--- a/cli.py
+++ b/cli.py
@@ -137,7 +137,7 @@ def main():
137 func = is_clean 137 func = is_clean
138 elif args.ugly is True: # destructive anonymisation method 138 elif args.ugly is True: # destructive anonymisation method
139 func = clean_meta_ugly 139 func = clean_meta_ugly
140 elif args.list is True: 140 elif args.list is True: # print the list of all supported format
141 list_supported() 141 list_supported()
142 else: # clean the file 142 else: # clean the file
143 func = clean_meta 143 func = clean_meta
diff --git a/gui.py b/gui.py
index c95697b..571db55 100644
--- a/gui.py
+++ b/gui.py
@@ -464,9 +464,9 @@ class TreeViewTooltips(object):
464 ''' 464 '''
465 as the pointer moves across the view, show a tooltip 465 as the pointer moves across the view, show a tooltip
466 ''' 466 '''
467 path = view.get_path_at_pos(int(event.x), int(event.y)) 467 path_at_pos = view.get_path_at_pos(int(event.x), int(event.y))
468 if path: 468 if path_at_pos:
469 path, col, x, y = path 469 path, col, x, y = path_at_pos
470 tooltip = self.get_tooltip(view, col, path) 470 tooltip = self.get_tooltip(view, col, path)
471 if tooltip: 471 if tooltip:
472 tooltip = str(tooltip).strip() 472 tooltip = str(tooltip).strip()
diff --git a/lib/archive.py b/lib/archive.py
index ee05d9e..3f16ee4 100644
--- a/lib/archive.py
+++ b/lib/archive.py
@@ -12,6 +12,7 @@ import parser
12import mat 12import mat
13import tarfile 13import tarfile
14 14
15
15class GenericArchiveStripper(parser.GenericParser): 16class GenericArchiveStripper(parser.GenericParser):
16 ''' 17 '''
17 Represent a generic archive 18 Represent a generic archive
@@ -48,6 +49,7 @@ class GenericArchiveStripper(parser.GenericParser):
48 ''' 49 '''
49 raise NotImplementedError 50 raise NotImplementedError
50 51
52
51class ZipStripper(GenericArchiveStripper): 53class ZipStripper(GenericArchiveStripper):
52 ''' 54 '''
53 Represent a zip file 55 Represent a zip file
@@ -231,7 +233,7 @@ class TarStripper(GenericArchiveStripper):
231 if item.type is '0': # is item a regular file ? 233 if item.type is '0': # is item a regular file ?
232 try: 234 try:
233 class_file = mat.create_class_file(name, 235 class_file = mat.create_class_file(name,
234 False, self.add2archive) #no backup file 236 False, self.add2archive) # no backup file
235 if not class_file.is_clean(): 237 if not class_file.is_clean():
236 tarin.close() 238 tarin.close()
237 return False 239 return False
diff --git a/lib/audio.py b/lib/audio.py
index 20cae6a..18daa7e 100644
--- a/lib/audio.py
+++ b/lib/audio.py
@@ -3,7 +3,6 @@
3''' 3'''
4try: 4try:
5 from mutagen.flac import FLAC 5 from mutagen.flac import FLAC
6 from mutagen.apev2 import APEv2File
7 from mutagen.oggvorbis import OggVorbis 6 from mutagen.oggvorbis import OggVorbis
8except ImportError: 7except ImportError:
9 pass 8 pass
@@ -57,43 +56,6 @@ class OggStripper(parser.GenericParser):
57 metadata[key] = value 56 metadata[key] = value
58 return metadata 57 return metadata
59 58
60class Apev2Stripper(parser.GenericParser):
61 '''
62 Represent a Apev2 audio file
63 '''
64 def remove_all(self):
65 '''
66 Remove the "metadata" block from the file
67 '''
68 if self.backup is True:
69 shutil.copy2(self.filename, self.output)
70 self.filename = self.output
71
72 mfile = APEv2File(self.filename)
73 mfile.delete()
74 mfile.save()
75
76 def is_clean(self):
77 '''
78 Check if the "metadata" block is present in the file
79 '''
80 mfile = APEv2File(self.filename)
81 if mfile.tags is None:
82 return True
83 else:
84 return False
85
86 def get_meta(self):
87 '''
88 Return the content of the metadata block if present
89 '''
90 metadata = {}
91 mfile = APEv2File(self.filename)
92 if mfile.tags is not None:
93 for key, value in mfile.tags:
94 metadata[key] = value
95 return metadata
96
97 59
98class FlacStripper(parser.GenericParser): 60class FlacStripper(parser.GenericParser):
99 ''' 61 '''
diff --git a/lib/mat.py b/lib/mat.py
index ad66d92..97a71ea 100644
--- a/lib/mat.py
+++ b/lib/mat.py
@@ -43,7 +43,8 @@ try:
43 STRIPPERS['application/x-pdf'] = office.PdfStripper 43 STRIPPERS['application/x-pdf'] = office.PdfStripper
44 STRIPPERS['application/pdf'] = office.PdfStripper 44 STRIPPERS['application/pdf'] = office.PdfStripper
45except ImportError: 45except ImportError:
46 print('Unable to import python-poppler and/or python-cairo: no pdf support') 46 print('Unable to import python-poppler and/or python-cairo: no pdf \
47 support')
47 48
48try: 49try:
49 import mutagen 50 import mutagen
@@ -62,7 +63,7 @@ class XMLParser(xml.sax.handler.ContentHandler):
62 self.dict = {} 63 self.dict = {}
63 self.list = [] 64 self.list = []
64 self.content, self.key = '', '' 65 self.content, self.key = '', ''
65 self.between= False 66 self.between = False
66 67
67 def startElement(self, name, attrs): 68 def startElement(self, name, attrs):
68 ''' 69 '''
@@ -142,7 +143,7 @@ def create_class_file(name, backup, add2archive):
142 143
143 mime = parser.mime_type 144 mime = parser.mime_type
144 145
145 if mime == 'application/zip': # some formats are zipped stuff 146 if mime == 'application/zip': # some formats are zipped stuff
146 mime = mimetypes.guess_type(name)[0] 147 mime = mimetypes.guess_type(name)[0]
147 148
148 if mime.startswith('application/vnd.oasis.opendocument'): 149 if mime.startswith('application/vnd.oasis.opendocument'):
diff --git a/lib/misc.py b/lib/misc.py
index acbaed8..963800e 100644
--- a/lib/misc.py
+++ b/lib/misc.py
@@ -1,3 +1,7 @@
1'''
2 Care about misc formats
3'''
4
1import hachoir_core 5import hachoir_core
2import parser 6import parser
3 7
diff --git a/lib/office.py b/lib/office.py
index bf50774..9c9d367 100644
--- a/lib/office.py
+++ b/lib/office.py
@@ -134,8 +134,8 @@ class PdfStripper(parser.GenericParser):
134 if self.document.get_property(key) != -1: 134 if self.document.get_property(key) != -1:
135 return False 135 return False
136 elif self.document.get_property(key) is not None and \ 136 elif self.document.get_property(key) is not None and \
137 self.document.get_property(key) != '': 137 self.document.get_property(key) != '':
138 return False 138 return False
139 return True 139 return True
140 140
141 def remove_all(self): 141 def remove_all(self):
@@ -179,7 +179,7 @@ class PdfStripper(parser.GenericParser):
179 metadata[key] = self.document.get_property(key) 179 metadata[key] = self.document.get_property(key)
180 elif self.document.get_property(key) is not None and \ 180 elif self.document.get_property(key) is not None and \
181 self.document.get_property(key) != '': 181 self.document.get_property(key) != '':
182 metadata[key] = self.document.get_property(key) 182 metadata[key] = self.document.get_property(key)
183 return metadata 183 return metadata
184 184
185 185
diff --git a/lib/parser.py b/lib/parser.py
index fd0ed13..e1b8f11 100644
--- a/lib/parser.py
+++ b/lib/parser.py
@@ -16,6 +16,7 @@ NOMETA = ('.bmp', '.rdf', '.txt', '.xml', '.rels')
16#xml : formated text 16#xml : formated text
17#rels : openxml foramted text 17#rels : openxml foramted text
18 18
19
19class GenericParser(object): 20class GenericParser(object):
20 ''' 21 '''
21 Parent class of all parsers 22 Parent class of all parsers