cellarspoon
3 years ago
No known key found for this signature in database
GPG Key ID: 3789458B3D0C410
1 changed files with
44 additions and
38 deletions
-
temp_index.py
|
|
@ -1,5 +1,7 @@ |
|
|
|
"""Generates PDF cards from a calibre metadata.db.""" |
|
|
|
|
|
|
|
from textwrap import shorten |
|
|
|
|
|
|
|
from calibrestekje import Book, Comment, Publisher, init_session |
|
|
|
from reportlab.lib.pagesizes import * |
|
|
|
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet |
|
|
@ -21,8 +23,6 @@ def get_fields(db_path, fields): |
|
|
|
session = init_session(db_path) |
|
|
|
|
|
|
|
for book in session.query(Book).all(): |
|
|
|
for comment in session.query(Comment).all(): |
|
|
|
|
|
|
|
if "title" in fields: |
|
|
|
tag = "<font size=12>{}</font>".format(book.title) |
|
|
|
ptitle = Paragraph(tag, styles["Italic"]) |
|
|
@ -36,7 +36,13 @@ def get_fields(db_path, fields): |
|
|
|
content.append(Spacer(1, 12)) |
|
|
|
|
|
|
|
if "comments" in fields: |
|
|
|
tag = "<font size=10>{}</font>".format(comment.text) |
|
|
|
comments = ", ".join( |
|
|
|
[ |
|
|
|
shorten(comment.text, width=50, placeholder="...") |
|
|
|
for comment in book.comments |
|
|
|
] |
|
|
|
) |
|
|
|
tag = "<font size=10>{}</font>".format(comments) |
|
|
|
pcomments = Paragraph(tag) |
|
|
|
content.append(pcomments) |
|
|
|
|
|
|
|