Make library card catalogue PDFs with Python scripts

From Parallel Library Services
Jump to navigation Jump to search

Dependencies

  • git, software for managing development and versioning repositories of code
  • an activated python virtual environment
  • scripts cloned from a git repository
  • installation of calibrestekje, a python-bindings library
  • a valid metadata.db file as produced by an existing installation of Calibre

Getting started

If you don't have git on your system, you can install it via instructions on this website:

https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

After installing git, you can clone repositories, and work on files on your computer. There are many other things you can do with git, for example push/pull changes, check version history and "fork" projects or work on them collaboratively.

First clone the git repository and change to the new bootleg/ directory::

git clone https://git.xpub.nl/simoon/bootleg.git
cd bootleg/

In the bootleg/ directory, create and activate a python virtual environment. Once activated, you'll notice the prompt in the terminal has changed to be prefaced by (venv), which indicates that the virtual environment is active.

python3 -m venv venv
source venv/bin/activate

Then, install dependencies in the python environment.

pip install reportlab calibrestekje pillow markdown html5lib

With Etherpad

lesssimplelayout.py is a script that uses You can use URLs created by Etherpad to


With Calibrestekje, Calibre and Reportlab

Calibrestkje works with an existing Calibre database. This means, a previously installed version of Calibre. If you don't have calibre installed yet, you should do this before trying out this recipe. The contents that are produced in the PDF depend entirely on what is in the metadata.db file. Alternatively, it may also be useful to install calibre and force it to make an empty, but valid file which can be written to using calibredb, a tool that comes with the calibre package. There is a handy guide for how to work with the Calibre database on the examples page for Calibrestekje.

Make sure you have a valid metadata.db file in the same bootleg/ directory. One which is usually produced the first time you run Calibre in a path similar to /home/myusername/calibre/metadata.db on Debian and Unix-like systems. This file is usually kept with the contents of the Calibre book collection.