From ff431ae30521f294ce4d97d31b19db93cb7c0195 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 30 Oct 2013 18:44:02 +0000 Subject: More pep8 conformance --- MAT/images.py | 6 +++--- MAT/mat.py | 8 ++++++-- MAT/misc.py | 8 ++++---- MAT/parser.py | 10 +++++----- 4 files changed, 18 insertions(+), 14 deletions(-) (limited to 'MAT') diff --git a/MAT/images.py b/MAT/images.py index dc96e6a..67c710f 100644 --- a/MAT/images.py +++ b/MAT/images.py @@ -42,9 +42,9 @@ class PngStripper(parser.GenericParser): ''' field_list = frozenset([ 'id', - 'header', # PNG header - 'physical', # the intended pixel size or aspect ratio - 'end']) # end of the image + 'header', # PNG header + 'physical', # the intended pixel size or aspect ratio + 'end']) # end of the image if field.name in field_list: return False if field.name.startswith('data['): # data diff --git a/MAT/mat.py b/MAT/mat.py index 092ef48..0359dd0 100644 --- a/MAT/mat.py +++ b/MAT/mat.py @@ -31,6 +31,7 @@ logging.basicConfig(filename=fname, level=LOGGING_LEVEL) import strippers # this is loaded here because we need LOGGING_LEVEL + def get_logo(): ''' Return the path to the logo ''' @@ -41,6 +42,7 @@ def get_logo(): elif os.path.isfile('/usr/local/share/pixmaps/mat.png'): return '/usr/local/share/pixmaps/mat.png' + def get_datadir(): ''' Return the path to the data directory ''' @@ -51,6 +53,7 @@ def get_datadir(): elif os.path.isdir('/usr/share/mat/'): return '/usr/share/mat/' + def list_supported_formats(): ''' Return a list of all locally supported fileformat. It parses that FORMATS file, and removes locally @@ -70,6 +73,7 @@ def list_supported_formats(): return localy_supported + class XMLParser(xml.sax.handler.ContentHandler): ''' Parse the supported format xml, and return a corresponding list of dict @@ -132,7 +136,7 @@ def create_class_file(name, backup, **kwargs): logging.error('%s is not a valid file' % name) return None - if not os.access(name, os.R_OK): #check read permissions + if not os.access(name, os.R_OK): # check read permissions logging.error('%s is is not readable' % name) return None @@ -156,7 +160,7 @@ def create_class_file(name, backup, **kwargs): if mime == 'application/zip': # some formats are zipped stuff if mimetypes.guess_type(name)[0]: - mime = mimetypes.guess_type(name)[0] + mime = mimetypes.guess_type(name)[0] if mime.startswith('application/vnd.oasis.opendocument'): mime = 'application/opendocument' # opendocument fileformat diff --git a/MAT/misc.py b/MAT/misc.py index 3f24ece..450f381 100644 --- a/MAT/misc.py +++ b/MAT/misc.py @@ -19,7 +19,7 @@ class TorrentStripper(parser.GenericParser): ''' Get recursively all keys from a dict and its subdicts ''' - for (i,j) in list(dictionary.items()): + for i, j in list(dictionary.items()): if isinstance(j, dict): return set([i]).union(self.__get_key_recursively(j)) return set([i]) @@ -35,7 +35,7 @@ class TorrentStripper(parser.GenericParser): ''' Get recursively all harmful metadata ''' d = dict() - for(i,j) in list(dictionary.items()): + for i, j in list(dictionary.items()): if i not in self.fields: d[i] = j elif isinstance(j, dict): @@ -53,7 +53,7 @@ class TorrentStripper(parser.GenericParser): ''' Remove recursively all compromizing fields ''' d = dict() - for (i,j) in [i for i in list(dictionary.items()) if i in self.fields]: + for i, j in [i for i in list(dictionary.items()) if i in self.fields]: if isinstance(j, dict): d = dict(list(d.items()) + list(self.__get_meta_recursively(j).items())) else: @@ -67,7 +67,7 @@ class TorrentStripper(parser.GenericParser): with open(self.filename, 'r') as f: decoded = bencode.bdecode(f.read()) - cleaned = {i:j for i,j in list(decoded.items()) if i in self.fields} + cleaned = {i: j for i, j in list(decoded.items()) if i in self.fields} with open(self.output, 'w') as f: # encode the decoded torrent f.write(bencode.bencode(cleaned)) # and write it in self.output diff --git a/MAT/parser.py b/MAT/parser.py index 8ef5aba..1765da8 100644 --- a/MAT/parser.py +++ b/MAT/parser.py @@ -11,11 +11,11 @@ import hachoir_editor import mat NOMETA = frozenset(( - '.bmp', # "raw" image - '.rdf', # text - '.txt', # plain text - '.xml', # formated text (XML) - '.rels', # openXML formated text + '.bmp', # "raw" image + '.rdf', # text + '.txt', # plain text + '.xml', # formated text (XML) + '.rels', # openXML formated text )) FIELD = object() -- cgit v1.3