Chore: Initial conversion to pytest fixtures (#7110)

This commit is contained in:
Trenton H
2024-07-08 07:46:20 -07:00
committed by GitHub
parent 1b9cf5121b
commit 3cf73a77ac
17 changed files with 1051 additions and 753 deletions

View File

@@ -1,4 +1,4 @@
import os
from pathlib import Path
from django.conf import settings
from PIL import Image
@@ -15,7 +15,7 @@ class TextDocumentParser(DocumentParser):
logging_name = "paperless.parsing.text"
def get_thumbnail(self, document_path, mime_type, file_name=None):
def get_thumbnail(self, document_path: Path, mime_type, file_name=None) -> Path:
text = self.read_file_handle_unicode_errors(document_path)
img = Image.new("RGB", (500, 700), color="white")
@@ -27,7 +27,7 @@ class TextDocumentParser(DocumentParser):
)
draw.text((5, 5), text, font=font, fill="black")
out_path = os.path.join(self.tempdir, "thumb.webp")
out_path = self.tempdir / "thumb.webp"
img.save(out_path, format="WEBP")
return out_path