mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 02:27:10 -04:00 
			
		
		
		
	make list checks consistent
Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
This commit is contained in:
		
							parent
							
								
									0ea5f5d584
								
							
						
					
					
						commit
						793f641af6
					
				| @ -79,12 +79,10 @@ def barcode_reader(image) -> list: | |||||||
|     # Decode the barcode image |     # Decode the barcode image | ||||||
|     detected_barcodes = pyzbar.decode(image) |     detected_barcodes = pyzbar.decode(image) | ||||||
| 
 | 
 | ||||||
|     if not detected_barcodes: |     if detected_barcodes: | ||||||
|         logger.debug("No barcode detected") |  | ||||||
|     else: |  | ||||||
|         # Traverse through all the detected barcodes in image |         # Traverse through all the detected barcodes in image | ||||||
|         for barcode in detected_barcodes: |         for barcode in detected_barcodes: | ||||||
|             if barcode.data != "": |             if barcode.data: | ||||||
|                 barcodes.append(str(barcode.data)) |                 barcodes.append(str(barcode.data)) | ||||||
|                 logger.debug( |                 logger.debug( | ||||||
|                     f"Barcode of type {str(barcode.type)} found: {str(barcode.data)}", |                     f"Barcode of type {str(barcode.type)} found: {str(barcode.data)}", | ||||||
| @ -122,7 +120,7 @@ def separate_pages(filepath: str, pages_to_split_on: list) -> list: | |||||||
|     pdf = Pdf.open(filepath) |     pdf = Pdf.open(filepath) | ||||||
|     document_paths = [] |     document_paths = [] | ||||||
|     logger.debug(f"Temp dir is {str(tempdir)}") |     logger.debug(f"Temp dir is {str(tempdir)}") | ||||||
|     if len(pages_to_split_on) <= 0: |     if not pages_to_split_on: | ||||||
|         logger.warning("No pages to split on!") |         logger.warning("No pages to split on!") | ||||||
|     else: |     else: | ||||||
|         # go from the first page to the first separator page |         # go from the first page to the first separator page | ||||||
| @ -188,14 +186,10 @@ def consume_file( | |||||||
|     if settings.CONSUMER_ENABLE_BARCODES: |     if settings.CONSUMER_ENABLE_BARCODES: | ||||||
|         separators = scan_file_for_separating_barcodes(path) |         separators = scan_file_for_separating_barcodes(path) | ||||||
|     document_list = [] |     document_list = [] | ||||||
|     if separators == []: |     if separators: | ||||||
|         pass |  | ||||||
|     else: |  | ||||||
|         logger.debug(f"Pages with separators found in: {str(path)}") |         logger.debug(f"Pages with separators found in: {str(path)}") | ||||||
|         document_list = separate_pages(path, separators) |         document_list = separate_pages(path, separators) | ||||||
|     if document_list == []: |     if document_list: | ||||||
|         pass |  | ||||||
|     else: |  | ||||||
|         for n, document in enumerate(document_list): |         for n, document in enumerate(document_list): | ||||||
|             # save to consumption dir |             # save to consumption dir | ||||||
|             # rename it to the original filename  with number prefix |             # rename it to the original filename  with number prefix | ||||||
|  | |||||||
| @ -187,9 +187,9 @@ class TestTasks(DirectoriesMixin, TestCase): | |||||||
|         ) |         ) | ||||||
|         tempdir = tempfile.mkdtemp(prefix="paperless-", dir=settings.SCRATCH_DIR) |         tempdir = tempfile.mkdtemp(prefix="paperless-", dir=settings.SCRATCH_DIR) | ||||||
|         separators = tasks.scan_file_for_separating_barcodes(test_file) |         separators = tasks.scan_file_for_separating_barcodes(test_file) | ||||||
|         self.assertTrue(separators != []) |         self.assertTrue(separators) | ||||||
|         document_list = tasks.separate_pages(test_file, separators) |         document_list = tasks.separate_pages(test_file, separators) | ||||||
|         self.assertTrue(document_list != []) |         self.assertTrue(document_list) | ||||||
|         for document in document_list: |         for document in document_list: | ||||||
|             tasks.save_to_dir(document, target_dir=tempdir) |             tasks.save_to_dir(document, target_dir=tempdir) | ||||||
|         target_file1 = os.path.join(tempdir, "patch-code-t-middle_document_0.pdf") |         target_file1 = os.path.join(tempdir, "patch-code-t-middle_document_0.pdf") | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user