A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
add split logic to consume_file
Florian Brandesb22742791625
diff --git a/requirements.txt b/requirements.txtindex afc8b9f51..26ec003f8 100644--- a/requirements.txt+++ b/requirements.txt@@ -61,6 +61,7 @@ ocrmypdf==13.4.2packaging==21.3; python_version >= '3.6'pathvalidate==2.5.0pdfminer.six==20220319+pdf2image==1.16.0pikepdf==5.1.1pillow==9.1.0pluggy==1.0.0; python_version >= '3.6'diff --git a/src/documents/tasks.py b/src/documents/tasks.pyindex 5161fcc01..eff46436e 100644--- a/src/documents/tasks.py+++ b/src/documents/tasks.py@@ -177,10 +177,26 @@ def consume_file():# check for separators in current document- separator_page_numbers = scan_file_for_separating_barcodes(path)- if separator_page_numbers != []:- logger.debug(f"Pages with separators found: {str(separator_page_numbers)}")-+ separators = scan_file_for_separating_barcodes(path)+ document_list = []+ if separators == []:+ pass+ else:+ logger.debug(f"Pages with separators found in: {str(path)}")+ document_list = separate_pages(path, separators)+ if document_list == []:+ pass+ else:+ for document in document_list:+ # save to consumption dir+ save_to_dir(document)+ # if we got here, the document was successfully split+ # and can safely be deleted+ logger.debug("Deleting file {}".format(path))+ os.unlink(path)+ return "File successfully split"++ # continue with consumption if no barcode was founddocument = Consumer().try_consume_file(path,override_filename=override_filename,