mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-10 00:18:57 +00:00
Runs the pre-commit hooks over all the Python files
This commit is contained in:
@@ -7,16 +7,16 @@ from contextlib import contextmanager
|
||||
import tqdm
|
||||
from django.conf import settings
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.db.models.signals import post_save, m2m_changed
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import CommandError
|
||||
from django.db.models.signals import m2m_changed
|
||||
from django.db.models.signals import post_save
|
||||
from documents.models import Document
|
||||
from documents.settings import EXPORTER_ARCHIVE_NAME
|
||||
from documents.settings import EXPORTER_FILE_NAME
|
||||
from documents.settings import EXPORTER_THUMBNAIL_NAME
|
||||
from filelock import FileLock
|
||||
|
||||
from documents.models import Document
|
||||
from documents.settings import (
|
||||
EXPORTER_FILE_NAME,
|
||||
EXPORTER_THUMBNAIL_NAME,
|
||||
EXPORTER_ARCHIVE_NAME,
|
||||
)
|
||||
from ...file_handling import create_source_path_directory
|
||||
from ...signals.handlers import update_filename_and_move_files
|
||||
|
||||
@@ -36,7 +36,8 @@ class Command(BaseCommand):
|
||||
Using a manifest.json file, load the data from there, and import the
|
||||
documents it refers to.
|
||||
""".replace(
|
||||
" ", ""
|
||||
" ",
|
||||
"",
|
||||
)
|
||||
|
||||
def add_arguments(self, parser):
|
||||
@@ -73,7 +74,9 @@ class Command(BaseCommand):
|
||||
|
||||
self._check_manifest()
|
||||
with disable_signal(
|
||||
post_save, receiver=update_filename_and_move_files, sender=Document
|
||||
post_save,
|
||||
receiver=update_filename_and_move_files,
|
||||
sender=Document,
|
||||
):
|
||||
with disable_signal(
|
||||
m2m_changed,
|
||||
@@ -92,7 +95,7 @@ class Command(BaseCommand):
|
||||
def _check_manifest_exists(path):
|
||||
if not os.path.exists(path):
|
||||
raise CommandError(
|
||||
"That directory doesn't appear to contain a manifest.json " "file."
|
||||
"That directory doesn't appear to contain a manifest.json " "file.",
|
||||
)
|
||||
|
||||
def _check_manifest(self):
|
||||
@@ -105,14 +108,14 @@ class Command(BaseCommand):
|
||||
if EXPORTER_FILE_NAME not in record:
|
||||
raise CommandError(
|
||||
"The manifest file contains a record which does not "
|
||||
"refer to an actual document file."
|
||||
"refer to an actual document file.",
|
||||
)
|
||||
|
||||
doc_file = record[EXPORTER_FILE_NAME]
|
||||
if not os.path.exists(os.path.join(self.source, doc_file)):
|
||||
raise CommandError(
|
||||
'The manifest file refers to "{}" which does not '
|
||||
"appear to be in the source directory.".format(doc_file)
|
||||
"appear to be in the source directory.".format(doc_file),
|
||||
)
|
||||
|
||||
if EXPORTER_ARCHIVE_NAME in record:
|
||||
@@ -120,7 +123,7 @@ class Command(BaseCommand):
|
||||
if not os.path.exists(os.path.join(self.source, archive_file)):
|
||||
raise CommandError(
|
||||
f"The manifest file refers to {archive_file} which "
|
||||
f"does not appear to be in the source directory."
|
||||
f"does not appear to be in the source directory.",
|
||||
)
|
||||
|
||||
def _import_files_from_manifest(self, progress_bar_disable):
|
||||
@@ -132,7 +135,7 @@ class Command(BaseCommand):
|
||||
print("Copy files into paperless...")
|
||||
|
||||
manifest_documents = list(
|
||||
filter(lambda r: r["model"] == "documents.document", self.manifest)
|
||||
filter(lambda r: r["model"] == "documents.document", self.manifest),
|
||||
)
|
||||
|
||||
for record in tqdm.tqdm(manifest_documents, disable=progress_bar_disable):
|
||||
|
Reference in New Issue
Block a user