diff options
| -rw-r--r-- | libmat2/archive.py | 4 | ||||
| -rw-r--r-- | libmat2/office.py | 3 | ||||
| -rw-r--r-- | libmat2/pdf.py | 1 | ||||
| -rw-r--r-- | libmat2/torrent.py | 1 | ||||
| -rw-r--r-- | nautilus/mat2.py | 5 | ||||
| -rw-r--r-- | tests/test_corrupted_files.py | 6 | ||||
| -rw-r--r-- | tests/test_deep_cleaning.py | 2 | ||||
| -rw-r--r-- | 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): | |||
| 25 | 25 | ||
| 26 | # what should the parser do if it encounters an unknown file in | 26 | # what should the parser do if it encounters an unknown file in |
| 27 | # the archive? | 27 | # the archive? |
| 28 | unknown_member_policy = UnknownMemberPolicy.ABORT # type: UnknownMemberPolicy | 28 | unknown_member_policy = UnknownMemberPolicy.ABORT # type: UnknownMemberPolicy |
| 29 | 29 | ||
| 30 | def __init__(self, filename): | 30 | def __init__(self, filename): |
| 31 | super().__init__(filename) | 31 | super().__init__(filename) |
| @@ -94,7 +94,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): | |||
| 94 | pass | 94 | pass |
| 95 | elif any(map(lambda r: r.search(item.filename), self.files_to_omit)): | 95 | elif any(map(lambda r: r.search(item.filename), self.files_to_omit)): |
| 96 | continue | 96 | continue |
| 97 | else: # supported files that we want to first clean, then add | 97 | else: # supported files that we want to first clean, then add |
| 98 | tmp_parser, mtype = parser_factory.get_parser(full_path) # type: ignore | 98 | tmp_parser, mtype = parser_factory.get_parser(full_path) # type: ignore |
| 99 | if not tmp_parser: | 99 | if not tmp_parser: |
| 100 | if self.unknown_member_policy == UnknownMemberPolicy.OMIT: | 100 | 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): | |||
| 138 | 138 | ||
| 139 | elements = list() | 139 | elements = list() |
| 140 | for element in tree.iterfind('.//w:ins', namespace): | 140 | for element in tree.iterfind('.//w:ins', namespace): |
| 141 | for position, item in enumerate(tree.iter()): #pragma: no cover | 141 | for position, item in enumerate(tree.iter()): # pragma: no cover |
| 142 | if item == element: | 142 | if item == element: |
| 143 | for children in element.iterfind('./*'): | 143 | for children in element.iterfind('./*'): |
| 144 | elements.append((element, position, children)) | 144 | elements.append((element, position, children)) |
| @@ -212,7 +212,6 @@ class LibreOfficeParser(ArchiveBasedAbstractParser): | |||
| 212 | '^Thumbnails/', | 212 | '^Thumbnails/', |
| 213 | })) | 213 | })) |
| 214 | 214 | ||
| 215 | |||
| 216 | @staticmethod | 215 | @staticmethod |
| 217 | def __remove_revisions(full_path: str) -> bool: | 216 | def __remove_revisions(full_path: str) -> bool: |
| 218 | try: | 217 | 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): | |||
| 118 | document.save('file://' + os.path.abspath(out_file)) | 118 | document.save('file://' + os.path.abspath(out_file)) |
| 119 | return True | 119 | return True |
| 120 | 120 | ||
| 121 | |||
| 122 | @staticmethod | 121 | @staticmethod |
| 123 | def __parse_metadata_field(data: str) -> dict: | 122 | def __parse_metadata_field(data: str) -> dict: |
| 124 | metadata = {} | 123 | 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): | |||
| 21 | metadata[key.decode('utf-8')] = value | 21 | metadata[key.decode('utf-8')] = value |
| 22 | return metadata | 22 | return metadata |
| 23 | 23 | ||
| 24 | |||
| 25 | def remove_all(self) -> bool: | 24 | def remove_all(self) -> bool: |
| 26 | cleaned = dict() | 25 | cleaned = dict() |
| 27 | for key, value in self.dict_repr.items(): | 26 | 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 | |||
| 104 | box.add(self.__create_treeview()) | 104 | box.add(self.__create_treeview()) |
| 105 | window.show_all() | 105 | window.show_all() |
| 106 | 106 | ||
| 107 | |||
| 108 | @staticmethod | 107 | @staticmethod |
| 109 | def __validate(fileinfo) -> Tuple[bool, str]: | 108 | def __validate(fileinfo) -> Tuple[bool, str]: |
| 110 | """ Validate if a given file FileInfo `fileinfo` can be processed. | 109 | """ Validate if a given file FileInfo `fileinfo` can be processed. |
| @@ -115,7 +114,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW | |||
| 115 | return False, "Not writeable" | 114 | return False, "Not writeable" |
| 116 | return True, "" | 115 | return True, "" |
| 117 | 116 | ||
| 118 | |||
| 119 | def __create_treeview(self) -> Gtk.TreeView: | 117 | def __create_treeview(self) -> Gtk.TreeView: |
| 120 | liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str) | 118 | liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str) |
| 121 | treeview = Gtk.TreeView(model=liststore) | 119 | treeview = Gtk.TreeView(model=liststore) |
| @@ -148,7 +146,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW | |||
| 148 | treeview.show_all() | 146 | treeview.show_all() |
| 149 | return treeview | 147 | return treeview |
| 150 | 148 | ||
| 151 | |||
| 152 | def __create_progressbar(self) -> Gtk.ProgressBar: | 149 | def __create_progressbar(self) -> Gtk.ProgressBar: |
| 153 | """ Create the progressbar used to notify that files are currently | 150 | """ Create the progressbar used to notify that files are currently |
| 154 | being processed. | 151 | being processed. |
| @@ -211,7 +208,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW | |||
| 211 | processing_queue.put(None) # signal that we processed all the files | 208 | processing_queue.put(None) # signal that we processed all the files |
| 212 | return True | 209 | return True |
| 213 | 210 | ||
| 214 | |||
| 215 | def __cb_menu_activate(self, menu, files): | 211 | def __cb_menu_activate(self, menu, files): |
| 216 | """ This method is called when the user clicked the "clean metadata" | 212 | """ This method is called when the user clicked the "clean metadata" |
| 217 | menu item. | 213 | menu item. |
| @@ -228,7 +224,6 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationW | |||
| 228 | thread.daemon = True | 224 | thread.daemon = True |
| 229 | thread.start() | 225 | thread.start() |
| 230 | 226 | ||
| 231 | |||
| 232 | def get_background_items(self, window, file): | 227 | def get_background_items(self, window, file): |
| 233 | """ https://bugzilla.gnome.org/show_bug.cgi?id=784278 """ | 228 | """ https://bugzilla.gnome.org/show_bug.cgi?id=784278 """ |
| 234 | return None | 229 | 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): | |||
| 146 | def test_docx(self): | 146 | def test_docx(self): |
| 147 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.docx') | 147 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.docx') |
| 148 | with self.assertRaises(ValueError): | 148 | with self.assertRaises(ValueError): |
| 149 | office.MSOfficeParser('./tests/data/clean.docx') | 149 | office.MSOfficeParser('./tests/data/clean.docx') |
| 150 | os.remove('./tests/data/clean.docx') | 150 | os.remove('./tests/data/clean.docx') |
| 151 | 151 | ||
| 152 | def test_flac(self): | 152 | def test_flac(self): |
| 153 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.flac') | 153 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.flac') |
| 154 | with self.assertRaises(ValueError): | 154 | with self.assertRaises(ValueError): |
| 155 | audio.FLACParser('./tests/data/clean.flac') | 155 | audio.FLACParser('./tests/data/clean.flac') |
| 156 | os.remove('./tests/data/clean.flac') | 156 | os.remove('./tests/data/clean.flac') |
| 157 | 157 | ||
| 158 | def test_mp3(self): | 158 | def test_mp3(self): |
| 159 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.mp3') | 159 | shutil.copy('./tests/data/dirty.png', './tests/data/clean.mp3') |
| 160 | with self.assertRaises(ValueError): | 160 | with self.assertRaises(ValueError): |
| 161 | audio.MP3Parser('./tests/data/clean.mp3') | 161 | audio.MP3Parser('./tests/data/clean.mp3') |
| 162 | os.remove('./tests/data/clean.mp3') | 162 | os.remove('./tests/data/clean.mp3') |
| 163 | 163 | ||
| 164 | def test_jpg(self): | 164 | 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): | |||
| 30 | self.assertEqual(item.date_time, (1980, 1, 1, 0, 0, 0)) | 30 | self.assertEqual(item.date_time, (1980, 1, 1, 0, 0, 0)) |
| 31 | self.assertEqual(item.create_system, 3) # 3 is UNIX | 31 | self.assertEqual(item.create_system, 3) # 3 is UNIX |
| 32 | 32 | ||
| 33 | |||
| 34 | def test_office(self): | 33 | def test_office(self): |
| 35 | shutil.copy('./tests/data/dirty.docx', './tests/data/clean.docx') | 34 | shutil.copy('./tests/data/dirty.docx', './tests/data/clean.docx') |
| 36 | p = office.MSOfficeParser('./tests/data/clean.docx') | 35 | p = office.MSOfficeParser('./tests/data/clean.docx') |
| @@ -50,7 +49,6 @@ class TestZipMetadata(unittest.TestCase): | |||
| 50 | os.remove('./tests/data/clean.docx') | 49 | os.remove('./tests/data/clean.docx') |
| 51 | os.remove('./tests/data/clean.cleaned.docx') | 50 | os.remove('./tests/data/clean.cleaned.docx') |
| 52 | 51 | ||
| 53 | |||
| 54 | def test_libreoffice(self): | 52 | def test_libreoffice(self): |
| 55 | shutil.copy('./tests/data/dirty.odt', './tests/data/clean.odt') | 53 | shutil.copy('./tests/data/dirty.odt', './tests/data/clean.odt') |
| 56 | p = office.LibreOfficeParser('./tests/data/clean.odt') | 54 | 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): | |||
| 55 | self.assertEqual(meta['producer'], 'pdfTeX-1.40.14') | 55 | self.assertEqual(meta['producer'], 'pdfTeX-1.40.14') |
| 56 | self.assertEqual(meta['creator'], "'Certified by IEEE PDFeXpress at 03/19/2016 2:56:07 AM'") | 56 | self.assertEqual(meta['creator'], "'Certified by IEEE PDFeXpress at 03/19/2016 2:56:07 AM'") |
| 57 | self.assertEqual(meta['DocumentID'], "uuid:4a1a79c8-404e-4d38-9580-5bc081036e61") | 57 | self.assertEqual(meta['DocumentID'], "uuid:4a1a79c8-404e-4d38-9580-5bc081036e61") |
| 58 | self.assertEqual(meta['PTEX.Fullbanner'], "This is pdfTeX, Version " \ | 58 | self.assertEqual(meta['PTEX.Fullbanner'], "This is pdfTeX, Version " |
| 59 | "3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) kpathsea " \ | 59 | "3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) kpathsea " |
| 60 | "version 6.1.1") | 60 | "version 6.1.1") |
| 61 | 61 | ||
| 62 | def test_torrent(self): | 62 | def test_torrent(self): |
| @@ -329,7 +329,6 @@ class TestCleaning(unittest.TestCase): | |||
| 329 | os.remove('./tests/data/clean.docx') | 329 | os.remove('./tests/data/clean.docx') |
| 330 | os.remove('./tests/data/clean.cleaned.docx') | 330 | os.remove('./tests/data/clean.cleaned.docx') |
| 331 | 331 | ||
| 332 | |||
| 333 | def test_libreoffice(self): | 332 | def test_libreoffice(self): |
| 334 | shutil.copy('./tests/data/dirty.odt', './tests/data/clean.odt') | 333 | shutil.copy('./tests/data/dirty.odt', './tests/data/clean.odt') |
| 335 | p = office.LibreOfficeParser('./tests/data/clean.odt') | 334 | p = office.LibreOfficeParser('./tests/data/clean.odt') |
| @@ -410,7 +409,6 @@ class TestCleaning(unittest.TestCase): | |||
| 410 | os.remove('./tests/data/clean.odf') | 409 | os.remove('./tests/data/clean.odf') |
| 411 | os.remove('./tests/data/clean.cleaned.odf') | 410 | os.remove('./tests/data/clean.cleaned.odf') |
| 412 | 411 | ||
| 413 | |||
| 414 | def test_odg(self): | 412 | def test_odg(self): |
| 415 | shutil.copy('./tests/data/dirty.odg', './tests/data/clean.odg') | 413 | shutil.copy('./tests/data/dirty.odg', './tests/data/clean.odg') |
| 416 | p = office.LibreOfficeParser('./tests/data/clean.odg') | 414 | p = office.LibreOfficeParser('./tests/data/clean.odg') |
