argument changes
This commit is contained in:
parent
a8b3e4f9b8
commit
7ab727bf7c
@ -15,8 +15,8 @@ from temp_index import make_cards
|
||||
|
||||
|
||||
make_cards(
|
||||
"catalogue.pdf",
|
||||
"/home/me/catalogue.pdf",
|
||||
"sqlite:///metadata.db",
|
||||
["title", "uploaded_at", "comments", "authors", "tags"]
|
||||
["title", "timestamp", "comments", "authors", "tags"]
|
||||
)
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "temp-index"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = ""
|
||||
authors = ["automatist", "simoon", "decentral1se"]
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
"""Generates PDF cards from a calibre metadata.db."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from textwrap import shorten
|
||||
|
||||
from calibrestekje import Book, Comment, Publisher, init_session
|
||||
@ -8,12 +11,16 @@ from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.platypus import PageBreak, Paragraph, SimpleDocTemplate, Spacer
|
||||
|
||||
CWD = Path().resolve()
|
||||
|
||||
def make_cards(filename, db_path, fields):
|
||||
|
||||
def make_cards(filepath, db_path, fields):
|
||||
"""The main entrypoint for card generation."""
|
||||
filename = os.path.basename(filepath)
|
||||
doc = create_doc(filename)
|
||||
content = get_fields(db_path, fields)
|
||||
doc.build(content)
|
||||
shutil.move(os.path.join(CWD, filename), filepath)
|
||||
|
||||
|
||||
def get_fields(db_path, fields):
|
||||
@ -29,8 +36,8 @@ def get_fields(db_path, fields):
|
||||
content.append(ptitle)
|
||||
content.append(Spacer(1, 12))
|
||||
|
||||
if "uploaded_at" in fields:
|
||||
tag = "<font size=10>Uploaded: {}</font>".format(book.timestamp)
|
||||
if "timestamp" in fields:
|
||||
tag = "<font size=10>Timestamp: {}</font>".format(book.timestamp)
|
||||
ptime = Paragraph(tag, styles["Normal"])
|
||||
content.append(ptime)
|
||||
content.append(Spacer(1, 12))
|
||||
|
Loading…
Reference in New Issue
Block a user