Browse Source

autoformatter says things

main
cellarspoon 3 years ago
parent
commit
f5b7ff0ccd
No known key found for this signature in database GPG Key ID: 3789458B3D0C410
  1. 30
      temp_index.py

30
temp_index.py

@ -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()
@ -27,18 +32,19 @@ for book in session.query(Book).all():
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))

Loading…
Cancel
Save