Commit 942a73fb authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

update

parent 711afccc
.ipynb_checkpoints/
calibre/
node_modules/
.sconsign.dblite
import os
from pathlib import Path
env = Environment(ENV = {'PATH' : os.environ['PATH']})
docs = Path("docs")
for book in docs.iterdir():
if book.is_dir():
for file in book.iterdir():
if file.is_file():
# print (file.suffix)
# if file.suffix.lower() == ".json":
# env.Command(f"{file.parent}/{file.stem}.md", [f"{file}", "templates/meta.md"], action="""jinjafy templates/meta.md < $SOURCE > $TARGET""")
# env.Command(f"{file.parent}/{file.stem}.html", f"{file.parent}/{file.stem}.md", action="""pandoc --from markdown --to html --css ../../meta.css --standalone --section-divs $SOURCE -o $TARGET""")
# env.Command(f"{file.parent}/{file.stem}.epub", f"{file.parent}/{file.stem}.md", action="""pandoc --from markdown --to epub --css meta.css $SOURCE -o $TARGET""")
# Ensure png => jpg
if file.suffix.lower() == ".png":
jpg = file.parent/ f"{file.stem}.jpg"
if not jpg.exists():
env.Command(str(jpg), str(file), action="""convert $SOURCE $TARGET""")
\ No newline at end of file
......@@ -107,27 +107,35 @@ for book in books_meta:
files = [x for x in bookpath.iterdir() if x.is_file()]
else:
files = []
# covers = [x for x in files if x.suffix.lower() == ".jpg"]
covers = [x for x in files if x.suffix.lower() == ".jpg"]
# pubs = [x for x in files if x.suffix.lower() in (".epub", ".pdf") and x.name != "meta.epub"]
pubs = files
pubs = [x for x in files if x.suffix.lower() not in (".jpg", ".png")]
pubs = [x for x in files if not x.name.startswith("verlag.")]
# print (bookpath, pubs)
cover_data = None
# if covers:
# with open(covers[0], "rb") as fin:
# cover_data = ('jpeg', fin.read())
if covers:
with open(covers[0], "rb") as fin:
cover_data = ('jpeg', fin.read())
# Make the "format map" (format files as dict with TYPE as keys)
formats = {}
if pubs:
for p in pubs:
formats[p.suffix.upper()] = str(p)
formats[p.suffix[1:].upper()] = str(p)
# if p.suffix.lower() == ".epub":
# formats["EPUB"] = str(p)
# # formats["EPUB"] = f"{book['path']}/{p.name}"
# elif p.suffix.lower() == ".pdf":
# formats["PDF"] = str(p)
if "EPUB" not in formats:
formats["EPUB"] = str(docs_path / f"{book['md5']}.epub")
# formats["EPUB"] = str(docs_path / f"{book['md5']}.epub")
formats["EPUB"] = str(bookpath / "verlag.epub")
if "PDF" not in formats:
# formats["PDF"] = str(docs_path / f"{book['md5']}.pdf")
formats["PDF"] = str(bookpath / "verlag.pdf")
if "MD" not in formats:
# formats["MD"] = str(docs_path / f"{book['md5']}.md")
formats["MD"] = str(bookpath / "verlag.md")
# Make the metadata object
md = Metadata(book['title'], authors)
......@@ -135,8 +143,8 @@ for book in books_meta:
md.pubdate = f"{book['year']}"
# is comments the description!
# if cover_data is not None:
# md.cover_data = cover_data
if cover_data is not None:
md.cover_data = cover_data
tags = ["Verlag"]
if 'projects' in book:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment