diff --git a/src/documents/tests/test_parsers.py b/src/documents/tests/test_parsers.py index 392c0504f..8da6470a4 100644 --- a/src/documents/tests/test_parsers.py +++ b/src/documents/tests/test_parsers.py @@ -114,8 +114,8 @@ class TestParserAvailability(TestCase): self.assertEqual(get_default_file_extension('application/zip'), ".zip") self.assertEqual(get_default_file_extension('aasdasd/dgfgf'), "") - self.assertEqual(get_parser_class_for_mime_type('application/pdf'), RasterisedDocumentParser) - self.assertEqual(get_parser_class_for_mime_type('text/plain'), TextDocumentParser) + self.assertIsInstance(get_parser_class_for_mime_type('application/pdf')(logging_group=None), RasterisedDocumentParser) + self.assertIsInstance(get_parser_class_for_mime_type('text/plain')(logging_group=None), TextDocumentParser) self.assertEqual(get_parser_class_for_mime_type('text/sdgsdf'), None) self.assertTrue(is_file_ext_supported('.pdf')) diff --git a/src/paperless_tesseract/signals.py b/src/paperless_tesseract/signals.py index 1e1cd1e1a..fedd08a92 100644 --- a/src/paperless_tesseract/signals.py +++ b/src/paperless_tesseract/signals.py @@ -1,9 +1,13 @@ -from .parsers import RasterisedDocumentParser + +def get_parser(*args, **kwargs): + from .parsers import RasterisedDocumentParser + + return RasterisedDocumentParser(*args, **kwargs) def tesseract_consumer_declaration(sender, **kwargs): return { - "parser": RasterisedDocumentParser, + "parser": get_parser, "weight": 0, "mime_types": { "application/pdf": ".pdf", diff --git a/src/paperless_text/signals.py b/src/paperless_text/signals.py index 1e0493f4f..833d0be28 100644 --- a/src/paperless_text/signals.py +++ b/src/paperless_text/signals.py @@ -1,9 +1,13 @@ -from .parsers import TextDocumentParser + +def get_parser(*args, **kwargs): + from .parsers import TextDocumentParser + + return TextDocumentParser(*args, **kwargs) def text_consumer_declaration(sender, **kwargs): return { - "parser": TextDocumentParser, + "parser": get_parser, "weight": 10, "mime_types": { "text/plain": ".txt", diff --git a/src/paperless_tika/__init__.py b/src/paperless_tika/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/paperless_tika/signals.py b/src/paperless_tika/signals.py index 137416abb..dbda377ca 100644 --- a/src/paperless_tika/signals.py +++ b/src/paperless_tika/signals.py @@ -1,9 +1,13 @@ -from .parsers import TikaDocumentParser + +def get_parser(*args, **kwargs): + from .parsers import TikaDocumentParser + + return TikaDocumentParser(*args, **kwargs) def tika_consumer_declaration(sender, **kwargs): return { - "parser": TikaDocumentParser, + "parser": get_parser, "weight": 10, "mime_types": { "application/msword": ".doc",