mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	lazy loading for parsers
This commit is contained in:
		| @@ -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')) | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
							
								
								
									
										0
									
								
								src/paperless_tika/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/paperless_tika/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -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", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler