]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Includes the progress bar
authorTrenton Holmes <holmes.trenton@gmail.com>
Tue, 31 May 2022 18:20:10 +0000 (11:20 -0700)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Sat, 2 Jul 2022 15:39:09 +0000 (08:39 -0700)
src/documents/management/commands/document_redo_ocr.py

index c35639487b89afb0703660bd547946780650faa5..c76218d9938defda5bf34c88b0d3918a365cf8d5 100644 (file)
@@ -3,6 +3,7 @@ import shutil
 from pathlib import Path
 from typing import Type
 
+import tqdm
 from django.core.exceptions import ObjectDoesNotExist
 from django.core.management.base import BaseCommand
 from documents.models import Document
@@ -21,6 +22,14 @@ class Command(BaseCommand):
     )
 
     def add_arguments(self, parser):
+
+        parser.add_argument(
+            "--no-progress-bar",
+            default=False,
+            action="store_true",
+            help="If set, the progress bar will not be shown",
+        )
+
         parser.add_argument(
             "documents",
             nargs="+",
@@ -33,9 +42,9 @@ class Command(BaseCommand):
 
         all_docs = Document.objects.all()
 
-        for doc_pk in args.documents:
+        for doc_pk in tqdm.tqdm(args.documents, disable=options["no_progress_bar"]):
             try:
-                self.stdout.write(f"Parsing document {doc_pk}")
+                self.stdout.write(self.style.INFO(f"Parsing document {doc_pk}"))
                 doc: Document = all_docs.get(pk=doc_pk)
             except ObjectDoesNotExist:
                 self.stdout.write(self.style.ERROR(f"Document {doc_pk} does not exist"))