diff --git a/README.md b/README.md
index ac347b8..f02e7f0 100644
--- a/README.md
+++ b/README.md
@@ -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"]
)
```
diff --git a/pyproject.toml b/pyproject.toml
index e2d219c..8579dc7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "temp-index"
-version = "0.1.0"
+version = "0.2.0"
description = ""
authors = ["automatist", "simoon", "decentral1se"]
diff --git a/temp_index.py b/temp_index.py
index aad3382..59a7cf7 100644
--- a/temp_index.py
+++ b/temp_index.py
@@ -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 = "Uploaded: {}".format(book.timestamp)
+ if "timestamp" in fields:
+ tag = "Timestamp: {}".format(book.timestamp)
ptime = Paragraph(tag, styles["Normal"])
content.append(ptime)
content.append(Spacer(1, 12))