mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-14 00:26:21 +00:00
Configures ruff as the one stop linter and resolves warnings it raised
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2016-03-28 19:09
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import gnupg
|
||||
import hashlib
|
||||
@@ -13,7 +11,7 @@ from django.template.defaultfilters import slugify
|
||||
from django.utils.termcolors import colorize as colourise # Spelling hurts me
|
||||
|
||||
|
||||
class GnuPG(object):
|
||||
class GnuPG:
|
||||
"""
|
||||
A handy singleton to use when handling encrypted files.
|
||||
"""
|
||||
@@ -27,11 +25,14 @@ class GnuPG(object):
|
||||
@classmethod
|
||||
def encrypted(cls, file_handle):
|
||||
return cls.gpg.encrypt_file(
|
||||
file_handle, recipients=None, passphrase=settings.PASSPHRASE, symmetric=True
|
||||
file_handle,
|
||||
recipients=None,
|
||||
passphrase=settings.PASSPHRASE,
|
||||
symmetric=True,
|
||||
).data
|
||||
|
||||
|
||||
class Document(object):
|
||||
class Document:
|
||||
"""
|
||||
Django's migrations restrict access to model methods, so this is a snapshot
|
||||
of the methods that existed at the time this migration was written, since
|
||||
@@ -49,9 +50,9 @@ class Document(object):
|
||||
def __str__(self):
|
||||
created = self.created.strftime("%Y%m%d%H%M%S")
|
||||
if self.correspondent and self.title:
|
||||
return "{}: {} - {}".format(created, self.correspondent, self.title)
|
||||
return f"{created}: {self.correspondent} - {self.title}"
|
||||
if self.correspondent or self.title:
|
||||
return "{}: {}".format(created, self.correspondent or self.title)
|
||||
return f"{created}: {self.correspondent or self.title}"
|
||||
return str(created)
|
||||
|
||||
@property
|
||||
@@ -60,7 +61,7 @@ class Document(object):
|
||||
settings.MEDIA_ROOT,
|
||||
"documents",
|
||||
"originals",
|
||||
"{:07}.{}.gpg".format(self.pk, self.file_type),
|
||||
f"{self.pk:07}.{self.file_type}.gpg",
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -88,7 +89,7 @@ def set_checksums(apps, schema_editor):
|
||||
" order."
|
||||
"\n",
|
||||
opts=("bold",),
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
sums = {}
|
||||
@@ -101,7 +102,7 @@ def set_checksums(apps, schema_editor):
|
||||
colourise("*", fg="green"),
|
||||
colourise("Generating a checksum for", fg="white"),
|
||||
colourise(document.file_name, fg="cyan"),
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
with document.source_file as encrypted:
|
||||
@@ -122,15 +123,16 @@ def set_checksums(apps, schema_editor):
|
||||
fg="yellow",
|
||||
),
|
||||
doc1=colourise(
|
||||
" * {} (id: {})".format(sums[checksum][1], sums[checksum][0]),
|
||||
f" * {sums[checksum][1]} (id: {sums[checksum][0]})",
|
||||
fg="red",
|
||||
),
|
||||
doc2=colourise(
|
||||
" * {} (id: {})".format(document.file_name, document.pk), fg="red"
|
||||
f" * {document.file_name} (id: {document.pk})",
|
||||
fg="red",
|
||||
),
|
||||
code=colourise(
|
||||
" $ echo 'DELETE FROM documents_document WHERE id = {pk};' | ./manage.py dbshell".format(
|
||||
pk=document.pk
|
||||
pk=document.pk,
|
||||
),
|
||||
fg="green",
|
||||
),
|
||||
@@ -171,7 +173,8 @@ class Migration(migrations.Migration):
|
||||
model_name="document",
|
||||
name="created",
|
||||
field=models.DateTimeField(
|
||||
db_index=True, default=django.utils.timezone.now
|
||||
db_index=True,
|
||||
default=django.utils.timezone.now,
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
|
Reference in New Issue
Block a user