autoformatter says things

This commit is contained in:
cellarspoon 2021-11-29 11:14:46 +01:00
parent 080d1e0d29
commit f5b7ff0ccd
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410

View File

@ -1,14 +1,19 @@
from calibrestekje import Book, Comment, Publisher, init_session
from reportlab.lib.pagesizes import * from reportlab.lib.pagesizes import *
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.pdfgen import canvas from reportlab.pdfgen import canvas
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak from reportlab.platypus import PageBreak, Paragraph, SimpleDocTemplate, Spacer
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from calibrestekje import Book, Publisher, Comment, init_session
pagewidth, pageheight = landscape(A6) pagewidth, pageheight = landscape(A6)
doc = SimpleDocTemplate("text.pdf", pagesize=landscape(A6), doc = SimpleDocTemplate(
rightMargin=18, leftMargin=18, "text.pdf",
topMargin=0, bottomMargin=18) pagesize=landscape(A6),
rightMargin=18,
leftMargin=18,
topMargin=0,
bottomMargin=18,
)
content = [] content = []
styles = getSampleStyleSheet() styles = getSampleStyleSheet()
@ -19,26 +24,27 @@ session = init_session("sqlite:///metadata.db")
for book in session.query(Book).all(): for book in session.query(Book).all():
for comment in session.query(Comment).all(): for comment in session.query(Comment).all():
if (book.id) == (comment.book): if (book.id) == (comment.book):
print (book.id) print(book.id)
print (book.title) print(book.title)
print (book.authors) print(book.authors)
print (book.timestamp) print(book.timestamp)
print (book.path) print(book.path)
print (book.tags) print(book.tags)
print (comment.text) print(comment.text)
# create a paragraph and append content to it - e.g. book.title, book.authors etc # create a paragraph and append content to it - e.g. book.title, book.authors etc
ptitle = Paragraph('<font size=12>{}</font>'.format(book.title), styles["Italic"]) ptitle = Paragraph("<font size=12>{}</font>".format(book.title), styles["Italic"])
ptime = Paragraph('<font size=10>Uploaded: {}</font>'.format(book.timestamp), styles["Normal"]) ptime = Paragraph(
pcomments = Paragraph('<font size=10>{}</font>'.format(comment.text)) "<font size=10>Uploaded: {}</font>".format(book.timestamp), styles["Normal"]
)
pcomments = Paragraph("<font size=10>{}</font>".format(comment.text))
# list comprehensions for authors and tags # list comprehensions for authors and tags
format_string = '<font size=12>{}</font>' format_string = "<font size=12>{}</font>"
all_authors = [author.name for author in book.authors] all_authors = [author.name for author in book.authors]
glued_together = format_string.format(", ".join(all_authors)) glued_together = format_string.format(", ".join(all_authors))
format_string = '<font size=10>{}</font>' format_string = "<font size=10>{}</font>"
all_tags = [tag.name for tag in book.tags] all_tags = [tag.name for tag in book.tags]
tags_glued_together = format_string.format(", ".join(all_tags)) tags_glued_together = format_string.format(", ".join(all_tags))
@ -75,5 +81,5 @@ for book in session.query(Book).all():
content.append(p) content.append(p)
content.append(PageBreak()) content.append(PageBreak())
content.append(Spacer(6, 12)) content.append(Spacer(6, 12))
doc.build(content) doc.build(content)