From 719cdf20fa8c9921b81eaf6bf3df0d50c790de82 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 24 Sep 2018 20:15:07 +0200 Subject: [PATCH] Second pass of minor formatting --- libmat2/archive.py | 4 ++-- libmat2/office.py | 3 +-- libmat2/pdf.py | 1 - libmat2/torrent.py | 1 - nautilus/mat2.py | 5 ----- tests/test_corrupted_files.py | 6 +++--- tests/test_deep_cleaning.py | 2 -- tests/test_libmat2.py | 6 ++---- 8 files changed, 8 insertions(+), 20 deletions(-) diff --git a/libmat2/archive.py b/libmat2/archive.py index dd63c50..d812531 100644 --- a/libmat2/archive.py +++ b/libmat2/archive.py @@ -25,7 +25,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): # what should the parser do if it encounters an unknown file in # the archive? - unknown_member_policy = UnknownMemberPolicy.ABORT # type: UnknownMemberPolicy + unknown_member_policy = UnknownMemberPolicy.ABORT # type: UnknownMemberPolicy def __init__(self, filename): super().__init__(filename) @@ -94,7 +94,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): pass elif any(map(lambda r: r.search(item.filename), self.files_to_omit)): continue - else: # supported files that we want to first clean, then add + else: # supported files that we want to first clean, then add tmp_parser, mtype = parser_factory.get_parser(full_path) # type: ignore if not tmp_parser: if self.unknown_member_policy == UnknownMemberPolicy.OMIT: diff --git a/libmat2/office.py b/libmat2/office.py index c6b324b..bad352b 100644 --- a/libmat2/office.py +++ b/libmat2/office.py @@ -138,7 +138,7 @@ class MSOfficeParser(ArchiveBasedAbstractParser): elements = list() for element in tree.iterfind('.//w:ins', namespace): - for position, item in enumerate(tree.iter()): #pragma: no cover + for position, item in enumerate(tree.iter()): # pragma: no cover if item == element: for children in element.iterfind('./*'): elements.append((element, position, children)) @@ -212,7 +212,6 @@ class LibreOfficeParser(ArchiveBasedAbstractParser): '^Thumbnails/', })) - @staticmethod def __remove_revisions(full_path: str) -> bool: try: diff --git a/libmat2/pdf.py b/libmat2/pdf.py index 5e19ef7..c8769aa 100644 --- a/libmat2/pdf.py +++ b/libmat2/pdf.py @@ -118,7 +118,6 @@ class PDFParser(abstract.AbstractParser): document.save('file://' + os.path.abspath(out_file)) return True - @staticmethod def __parse_metadata_field(data: str) -> dict: metadata = {} diff --git a/libmat2/torrent.py b/libmat2/torrent.py index 049807b..c56e971 100644 --- a/libmat2/torrent.py +++ b/libmat2/torrent.py @@ -21,7 +21,6 @@ class TorrentParser(abstract.AbstractParser): metadata[key.decode('utf-8')] = value return metadata - def remove_all(self) -> bool: cleaned = dict() for key, value in self.dict_repr.items(): diff --git a/nautilus/mat2.py b/nautilus/mat2.py index 133c56d..af49323 100644 --- a/nautilus/mat2.py +++ b/nautilus/mat2.py @@ -104,7 +104,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW box.add(self.__create_treeview()) window.show_all() - @staticmethod def __validate(fileinfo) -> Tuple[bool, str]: """ Validate if a given file FileInfo `fileinfo` can be processed. @@ -115,7 +114,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW return False, "Not writeable" return True, "" - def __create_treeview(self) -> Gtk.TreeView: liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str) treeview = Gtk.TreeView(model=liststore) @@ -148,7 +146,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW treeview.show_all() return treeview - def __create_progressbar(self) -> Gtk.ProgressBar: """ Create the progressbar used to notify that files are currently being processed. @@ -211,7 +208,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW processing_queue.put(None) # signal that we processed all the files return True - def __cb_menu_activate(self, menu, files): """ This method is called when the user clicked the "clean metadata" menu item. @@ -228,7 +224,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW thread.daemon = True thread.start() - def get_background_items(self, window, file): """ https://bugzilla.gnome.org/show_bug.cgi?id=784278 """ return None diff --git a/tests/test_corrupted_files.py b/tests/test_corrupted_files.py index aee1530..30039e6 100644 --- a/tests/test_corrupted_files.py +++ b/tests/test_corrupted_files.py @@ -146,19 +146,19 @@ class TestCorruptedFiles(unittest.TestCase): def test_docx(self): shutil.copy('./tests/data/dirty.png', './tests/data/clean.docx') with self.assertRaises(ValueError): - office.MSOfficeParser('./tests/data/clean.docx') + office.MSOfficeParser('./tests/data/clean.docx') os.remove('./tests/data/clean.docx') def test_flac(self): shutil.copy('./tests/data/dirty.png', './tests/data/clean.flac') with self.assertRaises(ValueError): - audio.FLACParser('./tests/data/clean.flac') + audio.FLACParser('./tests/data/clean.flac') os.remove('./tests/data/clean.flac') def test_mp3(self): shutil.copy('./tests/data/dirty.png', './tests/data/clean.mp3') with self.assertRaises(ValueError): - audio.MP3Parser('./tests/data/clean.mp3') + audio.MP3Parser('./tests/data/clean.mp3') os.remove('./tests/data/clean.mp3') def test_jpg(self): diff --git a/tests/test_deep_cleaning.py b/tests/test_deep_cleaning.py index 4f1920d..03db6c5 100644 --- a/tests/test_deep_cleaning.py +++ b/tests/test_deep_cleaning.py @@ -30,7 +30,6 @@ class TestZipMetadata(unittest.TestCase): self.assertEqual(item.date_time, (1980, 1, 1, 0, 0, 0)) self.assertEqual(item.create_system, 3) # 3 is UNIX - def test_office(self): shutil.copy('./tests/data/dirty.docx', './tests/data/clean.docx') p = office.MSOfficeParser('./tests/data/clean.docx') @@ -50,7 +49,6 @@ class TestZipMetadata(unittest.TestCase): os.remove('./tests/data/clean.docx') os.remove('./tests/data/clean.cleaned.docx') - def test_libreoffice(self): shutil.copy('./tests/data/dirty.odt', './tests/data/clean.odt') p = office.LibreOfficeParser('./tests/data/clean.odt') diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 7a1a9e7..cf13e03 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py @@ -55,8 +55,8 @@ class TestGetMeta(unittest.TestCase): self.assertEqual(meta['producer'], 'pdfTeX-1.40.14') self.assertEqual(meta['creator'], "'Certified by IEEE PDFeXpress at 03/19/2016 2:56:07 AM'") self.assertEqual(meta['DocumentID'], "uuid:4a1a79c8-404e-4d38-9580-5bc081036e61") - self.assertEqual(meta['PTEX.Fullbanner'], "This is pdfTeX, Version " \ - "3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) kpathsea " \ + self.assertEqual(meta['PTEX.Fullbanner'], "This is pdfTeX, Version " + "3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) kpathsea " "version 6.1.1") def test_torrent(self): @@ -329,7 +329,6 @@ class TestCleaning(unittest.TestCase): os.remove('./tests/data/clean.docx') os.remove('./tests/data/clean.cleaned.docx') - def test_libreoffice(self): shutil.copy('./tests/data/dirty.odt', './tests/data/clean.odt') p = office.LibreOfficeParser('./tests/data/clean.odt') @@ -410,7 +409,6 @@ class TestCleaning(unittest.TestCase): os.remove('./tests/data/clean.odf') os.remove('./tests/data/clean.cleaned.odf') - def test_odg(self): shutil.copy('./tests/data/dirty.odg', './tests/data/clean.odg') p = office.LibreOfficeParser('./tests/data/clean.odg')