Format Python code with black

This commit is contained in:
kpj
2022-02-27 15:26:41 +01:00
parent 13885968e3
commit fc695896dd
136 changed files with 6142 additions and 3811 deletions

View File

@@ -14,9 +14,8 @@ class TextDocumentParser(DocumentParser):
logging_name = "paperless.parsing.text"
def get_thumbnail(self, document_path, mime_type, file_name=None):
def read_text():
with open(document_path, 'r') as src:
with open(document_path, "r") as src:
lines = [line.strip() for line in src.readlines()]
text = "\n".join(lines[:50])
return text
@@ -26,7 +25,8 @@ class TextDocumentParser(DocumentParser):
font = ImageFont.truetype(
font=settings.THUMBNAIL_FONT_NAME,
size=20,
layout_engine=ImageFont.LAYOUT_BASIC)
layout_engine=ImageFont.LAYOUT_BASIC,
)
draw.text((5, 5), read_text(), font=font, fill="black")
out_path = os.path.join(self.tempdir, "thumb.png")
@@ -35,5 +35,5 @@ class TextDocumentParser(DocumentParser):
return out_path
def parse(self, document_path, mime_type, file_name=None):
with open(document_path, 'r') as f:
with open(document_path, "r") as f:
self.text = f.read()