A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
remove lots of unused code
jonaswinkler0d3ab3aaf747
diff --git a/src/documents/management/commands/document_archiver.py b/src/documents/management/commands/document_archiver.pyindex 01bd819c5..9e0d8fabf 100644--- a/src/documents/management/commands/document_archiver.py+++ b/src/documents/management/commands/document_archiver.py@@ -17,7 +17,6 @@ from whoosh.writing import AsyncWriterfrom documents.models import Documentfrom ... import indexfrom ...file_handling import create_source_path_directory-from ...mixins import Renderablefrom ...parsers import get_parser_class_for_mime_type@@ -62,7 +61,7 @@ def handle_document(document_id):parser.cleanup()-class Command(Renderable, BaseCommand):+class Command(BaseCommand):help = """Using the current classification model, assigns correspondents, tags@@ -71,10 +70,6 @@ class Command(Renderable, BaseCommand):modified) after their initial import.""".replace(" ", "")- def __init__(self, *args, **kwargs):- self.verbosity = 0- BaseCommand.__init__(self, *args, **kwargs)-def add_arguments(self, parser):parser.add_argument("-f", "--overwrite",diff --git a/src/documents/management/commands/document_create_classifier.py b/src/documents/management/commands/document_create_classifier.pyindex fbfb7f7e6..a4ede88b5 100755--- a/src/documents/management/commands/document_create_classifier.py+++ b/src/documents/management/commands/document_create_classifier.py@@ -1,10 +1,9 @@from django.core.management.base import BaseCommand-from ...mixins import Renderablefrom ...tasks import train_classifier-class Command(Renderable, BaseCommand):+class Command(BaseCommand):help = """Trains the classifier on your data and saves the resulting models to adiff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.pyindex 37fcf2024..1505b0856 100644--- a/src/documents/management/commands/document_exporter.py+++ b/src/documents/management/commands/document_exporter.py@@ -16,10 +16,9 @@ from documents.settings import EXPORTER_FILE_NAME, EXPORTER_THUMBNAIL_NAME, \EXPORTER_ARCHIVE_NAMEfrom paperless.db import GnuPGfrom ...file_handling import generate_filename, delete_empty_directories-from ...mixins import Renderable-class Command(Renderable, BaseCommand):+class Command(BaseCommand):help = """Decrypt and rename all files in our collection into a given targetdiff --git a/src/documents/management/commands/document_importer.py b/src/documents/management/commands/document_importer.pyindex a2e19e3cc..7e5d32085 100644--- a/src/documents/management/commands/document_importer.py+++ b/src/documents/management/commands/document_importer.py@@ -15,7 +15,6 @@ from documents.models import Documentfrom documents.settings import EXPORTER_FILE_NAME, EXPORTER_THUMBNAIL_NAME, \EXPORTER_ARCHIVE_NAMEfrom ...file_handling import create_source_path_directory-from ...mixins import Renderablefrom ...signals.handlers import update_filename_and_move_files@@ -28,7 +27,7 @@ def disable_signal(sig, receiver, sender):sig.connect(receiver=receiver, sender=sender)-class Command(Renderable, BaseCommand):+class Command(BaseCommand):help = """Using a manifest.json file, load the data from there, and import thediff --git a/src/documents/management/commands/document_index.py b/src/documents/management/commands/document_index.pyindex 08e20e1d2..5faa70b9f 100644--- a/src/documents/management/commands/document_index.py+++ b/src/documents/management/commands/document_index.py@@ -1,24 +1,17 @@from django.core.management import BaseCommandfrom django.db import transaction-from documents.mixins import Renderablefrom documents.tasks import index_reindex, index_optimize-class Command(Renderable, BaseCommand):+class Command(BaseCommand):help = "Manages the document index."- def __init__(self, *args, **kwargs):- self.verbosity = 0- BaseCommand.__init__(self, *args, **kwargs)-def add_arguments(self, parser):parser.add_argument("command", choices=['reindex', 'optimize'])def handle(self, *args, **options):-- self.verbosity = options["verbosity"]with transaction.atomic():if options['command'] == 'reindex':index_reindex()diff --git a/src/documents/management/commands/document_logs.py b/src/documents/management/commands/document_logs.pydeleted file mode 100644index 06efc3850..000000000--- a/src/documents/management/commands/document_logs.py+++ /dev/null@@ -1,12 +0,0 @@-from django.core.management.base import BaseCommand--from documents.models import Log---class Command(BaseCommand):-- help = "A quick & dirty way to see what's in the logs"-- def handle(self, *args, **options):- for log in Log.objects.order_by("pk"):- print(log)diff --git a/src/documents/management/commands/document_renamer.py b/src/documents/management/commands/document_renamer.pyindex 745d2d03d..f311715c6 100644--- a/src/documents/management/commands/document_renamer.py+++ b/src/documents/management/commands/document_renamer.py@@ -5,23 +5,16 @@ from django.core.management.base import BaseCommandfrom django.db.models.signals import post_savefrom documents.models import Document-from ...mixins import Renderable-class Command(Renderable, BaseCommand):+class Command(BaseCommand):help = """This will rename all documents to match the latest filename format.""".replace(" ", "")- def __init__(self, *args, **kwargs):- self.verbosity = 0- BaseCommand.__init__(self, *args, **kwargs)-def handle(self, *args, **options):- self.verbosity = options["verbosity"]-logging.getLogger().handlers[0].level = logging.ERRORfor document in tqdm.tqdm(Document.objects.all()):diff --git a/src/documents/management/commands/document_retagger.py b/src/documents/management/commands/document_retagger.pyindex b2f5d8918..a37ab9ef2 100755--- a/src/documents/management/commands/document_retagger.py+++ b/src/documents/management/commands/document_retagger.py@@ -4,11 +4,10 @@ from django.core.management.base import BaseCommandfrom documents.classifier import load_classifierfrom documents.models import Document-from ...mixins import Renderablefrom ...signals.handlers import set_correspondent, set_document_type, set_tags-class Command(Renderable, BaseCommand):+class Command(BaseCommand):help = """Using the current classification model, assigns correspondents, tags@@ -17,10 +16,6 @@ class Command(Renderable, BaseCommand):modified) after their initial import.""".replace(" ", "")- def __init__(self, *args, **kwargs):- self.verbosity = 0- BaseCommand.__init__(self, *args, **kwargs)-def add_arguments(self, parser):parser.add_argument("-c", "--correspondent",@@ -61,8 +56,6 @@ class Command(Renderable, BaseCommand):def handle(self, *args, **options):- self.verbosity = options["verbosity"]-if options["inbox_only"]:queryset = Document.objects.filter(tags__is_inbox_tag=True)else:diff --git a/src/documents/management/commands/document_thumbnails.py b/src/documents/management/commands/document_thumbnails.pyindex 6f6451599..cf2cbeb77 100644--- a/src/documents/management/commands/document_thumbnails.py+++ b/src/documents/management/commands/document_thumbnails.py@@ -7,7 +7,6 @@ from django import dbfrom django.core.management.base import BaseCommandfrom documents.models import Document-from ...mixins import Renderablefrom ...parsers import get_parser_class_for_mime_type@@ -30,16 +29,12 @@ def _process_document(doc_in):parser.cleanup()-class Command(Renderable, BaseCommand):+class Command(BaseCommand):help = """This will regenerate the thumbnails for all documents.""".replace(" ", "")- def __init__(self, *args, **kwargs):- self.verbosity = 0- BaseCommand.__init__(self, *args, **kwargs)-def add_arguments(self, parser):parser.add_argument("-d", "--document",@@ -51,9 +46,6 @@ class Command(Renderable, BaseCommand):)def handle(self, *args, **options):-- self.verbosity = options["verbosity"]-logging.getLogger().handlers[0].level = logging.ERRORif options['document']:diff --git a/src/documents/mixins.py b/src/documents/mixins.pydeleted file mode 100755index 949be02e8..000000000--- a/src/documents/mixins.py+++ /dev/null@@ -1,9 +0,0 @@-class Renderable:- """- A handy mixin to make it easier/cleaner to print output based on a- verbosity value.- """-- def _render(self, text, verbosity):- if self.verbosity >= verbosity:- print(text)