mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Unlocks all things which were locked due to ARMv7, etc
This commit is contained in:
@@ -182,8 +182,8 @@ class Command(BaseCommand):
|
||||
doc_path = self.source / doc_file
|
||||
if not doc_path.exists():
|
||||
raise CommandError(
|
||||
'The manifest file refers to "{}" which does not '
|
||||
"appear to be in the source directory.".format(doc_file),
|
||||
f'The manifest file refers to "{doc_file}" which does not '
|
||||
"appear to be in the source directory.",
|
||||
)
|
||||
try:
|
||||
with doc_path.open(mode="rb") as infile:
|
||||
|
@@ -530,9 +530,9 @@ class DocumentListSerializer(serializers.Serializer):
|
||||
)
|
||||
|
||||
def _validate_document_id_list(self, documents, name="documents"):
|
||||
if not type(documents) == list:
|
||||
if not isinstance(documents, list):
|
||||
raise serializers.ValidationError(f"{name} must be a list")
|
||||
if not all(type(i) == int for i in documents):
|
||||
if not all(isinstance(i, int) for i in documents):
|
||||
raise serializers.ValidationError(f"{name} must be a list of integers")
|
||||
count = Document.objects.filter(id__in=documents).count()
|
||||
if not count == len(documents):
|
||||
@@ -565,9 +565,9 @@ class BulkEditSerializer(DocumentListSerializer, SetPermissionsMixin):
|
||||
parameters = serializers.DictField(allow_empty=True)
|
||||
|
||||
def _validate_tag_id_list(self, tags, name="tags"):
|
||||
if not type(tags) == list:
|
||||
if not isinstance(tags, list):
|
||||
raise serializers.ValidationError(f"{name} must be a list")
|
||||
if not all(type(i) == int for i in tags):
|
||||
if not all(isinstance(i, int) for i in tags):
|
||||
raise serializers.ValidationError(f"{name} must be a list of integers")
|
||||
count = Tag.objects.filter(id__in=tags).count()
|
||||
if not count == len(tags):
|
||||
@@ -932,9 +932,9 @@ class AcknowledgeTasksViewSerializer(serializers.Serializer):
|
||||
|
||||
def _validate_task_id_list(self, tasks, name="tasks"):
|
||||
pass
|
||||
if not type(tasks) == list:
|
||||
if not isinstance(tasks, list):
|
||||
raise serializers.ValidationError(f"{name} must be a list")
|
||||
if not all(type(i) == int for i in tasks):
|
||||
if not all(isinstance(i, int) for i in tasks):
|
||||
raise serializers.ValidationError(f"{name} must be a list of integers")
|
||||
count = PaperlessTask.objects.filter(id__in=tasks).count()
|
||||
if not count == len(tasks):
|
||||
|
@@ -43,7 +43,7 @@ class StandardPagination(PageNumberPagination):
|
||||
if hasattr(self.page.paginator.object_list, "saved_results"):
|
||||
results_page = self.page.paginator.object_list.saved_results[0]
|
||||
if results_page is not None:
|
||||
for i in range(0, len(results_page.results.docs())):
|
||||
for i in range(len(results_page.results.docs())):
|
||||
try:
|
||||
fields = results_page.results.fields(i)
|
||||
if "id" in fields:
|
||||
|
@@ -151,7 +151,7 @@ class TagMailAction(BaseMailAction):
|
||||
_, self.color = parameter.split(":")
|
||||
self.color = self.color.strip()
|
||||
|
||||
if self.color.lower() not in APPLE_MAIL_TAG_COLORS.keys():
|
||||
if self.color.lower() not in APPLE_MAIL_TAG_COLORS:
|
||||
raise MailError("Not a valid AppleMail tag color.")
|
||||
|
||||
self.keyword = None
|
||||
|
@@ -9,7 +9,7 @@ from bleach import linkify
|
||||
from django.conf import settings
|
||||
from django.utils.timezone import is_naive
|
||||
from django.utils.timezone import make_aware
|
||||
from humanfriendly import format_size
|
||||
from humanize import naturalsize
|
||||
from imap_tools import MailAttachment
|
||||
from imap_tools import MailMessage
|
||||
from tika_client import TikaClient
|
||||
@@ -72,7 +72,7 @@ class MailDocumentParser(DocumentParser):
|
||||
"key": "attachments",
|
||||
"value": ", ".join(
|
||||
f"{attachment.filename}"
|
||||
f"({format_size(attachment.size, binary=True)})"
|
||||
f"({naturalsize(attachment.size, binary=True, format='%.2f')})"
|
||||
for attachment in mail.attachments
|
||||
),
|
||||
},
|
||||
@@ -124,7 +124,10 @@ class MailDocumentParser(DocumentParser):
|
||||
if mail_message.attachments:
|
||||
att = []
|
||||
for a in mail.attachments:
|
||||
att.append(f"{a.filename} ({format_size(a.size, binary=True)})")
|
||||
attachment_size = naturalsize(a.size, binary=True, format="%.2f")
|
||||
att.append(
|
||||
f"{a.filename} ({attachment_size})",
|
||||
)
|
||||
fmt_text += f"Attachments: {', '.join(att)}\n\n"
|
||||
|
||||
if mail.html:
|
||||
@@ -247,7 +250,7 @@ class MailDocumentParser(DocumentParser):
|
||||
"""
|
||||
if isinstance(text, list):
|
||||
text = "\n".join([str(e) for e in text])
|
||||
if type(text) != str:
|
||||
if not isinstance(text, str):
|
||||
text = str(text)
|
||||
text = escape(text)
|
||||
text = clean(text)
|
||||
@@ -275,7 +278,9 @@ class MailDocumentParser(DocumentParser):
|
||||
|
||||
att = []
|
||||
for a in mail.attachments:
|
||||
att.append(f"{a.filename} ({format_size(a.size, binary=True)})")
|
||||
att.append(
|
||||
f"{a.filename} ({naturalsize(a.size, binary=True, format='%.2f')})",
|
||||
)
|
||||
data["attachments"] = clean_html(", ".join(att))
|
||||
if data["attachments"]:
|
||||
data["attachments_label"] = "Attachments"
|
||||
|
Reference in New Issue
Block a user