From 6ba3e3f20d7d52895bc44f9fc35b068cfce47133 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 25 Jul 2015 17:14:23 +0200 Subject: _MASSIVE_ pep8 revamp Thank you so much PyCharm --- libmat/parser.py | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'libmat/parser.py') diff --git a/libmat/parser.py b/libmat/parser.py index 1765da8..eed3140 100644 --- a/libmat/parser.py +++ b/libmat/parser.py @@ -1,5 +1,5 @@ -''' Parent class of all parser -''' +""" Parent class of all parser +""" import os import shutil @@ -22,8 +22,8 @@ FIELD = object() class GenericParser(object): - ''' Parent class of all parsers - ''' + """ Parent class of all parsers + """ def __init__(self, filename, parser, mime, backup, is_writable, **kwargs): self.filename = '' self.parser = parser @@ -40,15 +40,15 @@ class GenericParser(object): self.output = hachoir_core.cmd_line.unicodeFilename(output) def __del__(self): - ''' Remove tempfile if it was not used - ''' + """ Remove tempfile if it was not used + """ if os.path.exists(self.output): mat.secure_remove(self.output) def is_clean(self): - ''' + """ Check if the file is clean from harmful metadatas - ''' + """ for field in self.editor: if self._should_remove(field): return self._is_clean(self.editor) @@ -65,16 +65,16 @@ class GenericParser(object): return True def remove_all(self): - ''' Remove all compromising fields - ''' + """ Remove all compromising fields + """ state = self._remove_all(self.editor) hachoir_core.field.writeIntoFile(self.editor, self.output) self.do_backup() return state def _remove_all(self, fieldset): - ''' Recursive way to handle tree metadatas - ''' + """ Recursive way to handle tree metadatas + """ try: for field in fieldset: remove = self._should_remove(field) @@ -87,20 +87,20 @@ class GenericParser(object): return False def _remove(self, fieldset, field): - ''' Delete the given field - ''' + """ Delete the given field + """ del fieldset[field] def get_meta(self): - ''' Return a dict with all the meta of the file - ''' + """ Return a dict with all the meta of the file + """ metadata = {} self._get_meta(self.editor, metadata) return metadata def _get_meta(self, fieldset, metadata): - ''' Recursive way to handle tree metadatas - ''' + """ Recursive way to handle tree metadatas + """ for field in fieldset: remove = self._should_remove(field) if remove: @@ -112,22 +112,22 @@ class GenericParser(object): self._get_meta(field, None) def _should_remove(self, key): - ''' Return True if the field is compromising + """ Return True if the field is compromising abstract method - ''' + """ raise NotImplementedError def create_backup_copy(self): - ''' Create a backup copy - ''' + """ Create a backup copy + """ shutil.copy2(self.filename, self.filename + '.bak') def do_backup(self): - ''' Keep a backup of the file if asked. + """ Keep a backup of the file if asked. The process of double-renaming is not very elegant, but it greatly simplify new strippers implementation. - ''' + """ if self.backup: shutil.move(self.filename, self.filename + '.bak') else: -- cgit v1.3