paperless-ngx/src/documents/management/commands/document_redo_ocr.py

36 lines
851 B
Python
Raw Normal View History

2022-05-31 11:20:10 -07:00
import tqdm
from django.core.management.base import BaseCommand
2022-06-22 05:53:13 -07:00
from documents.tasks import redo_ocr
class Command(BaseCommand):
help = """
This will rename all documents to match the latest filename format.
""".replace(
" ",
"",
)
def add_arguments(self, parser):
2022-05-31 11:20:10 -07:00
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="+",
help="Document primary keys for re-processing OCR on",
)
def handle(self, *args, **options):
2022-06-22 05:53:13 -07:00
doc_pks = tqdm.tqdm(
2022-06-10 11:23:24 -07:00
options["documents"],
disable=options["no_progress_bar"],
2022-06-22 05:53:13 -07:00
)
redo_ocr(doc_pks)