bibble.metadata.metadata_writer
See EOF for license/metadata/notes as applicable
Type Aliases
Classes
Apply metadata to files mentioned in bibtex entries |
|
Like ApplyMetadata, but just checks for files that can't be modified or are missing, |
|
Mixin for getting the paths of files in the entry |
|
A Mixin for epub-specific metadata manipulation |
|
A mixin for checking the metadata fof files |
|
A Mixin for pdf specific metadata manipulation |
Module Contents
- bibble.metadata.metadata_writer.Field: TypeAlias = model.Field
- class bibble.metadata.metadata_writer.ApplyMetadata(
- *,
- backup=None,
- force=False,
- **kwargs,
Bases:
bibble.util.middlecore.IdenBlockMiddleware- Apply metadata to files mentioned in bibtex entries
uses xmp-prism tags and some custom ones for pdfs, and epub standard.
TODO add a ‘meta_update’ status field to the entry for [locked,failed]
- Parameters:
backup (jgdv.Maybe[pathlib.Path])
force (bool)
- on_write() <Unknown>
- process_epub(epub, entry) <Unknown>
- Parameters:
epub (pathlib.Path)
entry (Entry)
- Return type:
list[Field]
- process_pdf(pdf, entry) <Unknown>
- Parameters:
pdf (pathlib.Path)
entry (Entry)
- Return type:
list[Field]
- transform_Entry(entry, library) <Unknown>
- Parameters:
entry (Entry)
library (bibble._interface.Library_p)
- Return type:
list[Entry]
- _backup: jgdv.Maybe[pathlib.path]
- _force_update = False
- class bibble.metadata.metadata_writer.FileCheck(*args, **kwargs)
Bases:
bibble.util.middlecore.IdenBlockMiddlewareLike ApplyMetadata, but just checks for files that can’t be modified or are missing, so they can be fixed. ie: its faster
Annotate entries with ‘pdf_locked’ if the pdf can’t be modified, “orphan_file” if the pdf or epub does not exist
- transform_Entry(entry, library) <Unknown>
TODO remove orphan/lock field if its no longer the case
- Parameters:
entry (Entry)
library (bibble._interface.Library_p)
- Return type:
list[Entry]
- class bibble.metadata.metadata_writer._EntryFileGetter_m
Mixin for getting the paths of files in the entry can return a list of all file_{N} field values
- _get_file(entry) <Unknown>
Gets the main file fields path of an entry
- Parameters:
entry (Entry)
- Return type:
jgdv.Maybe[pathlib.Path]
- _get_files(entry) <Unknown>
gets all paths of fields with ‘file’ in the field name
- Parameters:
entry (Entry)
- Return type:
- class bibble.metadata.metadata_writer._Epub_Update_m
A Mixin for epub-specific metadata manipulation
- update_epub_by_calibre(path, entry) <Unknown>
Uses calibre to modify epub metadata https://manual.calibre-ebook.com/generated/en/cli-index.html
- Parameters:
path (pathlib.Path)
entry (Entry)
- Return type:
None
- class bibble.metadata.metadata_writer._Metadata_Check_m
A mixin for checking the metadata fof files
- backup_original_metadata(path) <Unknown>
If self._backup is set, backup the files metadata as jsonlines there Uses exiftool to export the metadata as json, which is then appended into the backup as a jsonlines file.
- Parameters:
path (pathlib.Path)
- Return type:
None
- metadata_matches_entry(path, entry) <Unknown>
Test the given path to see if the metadata matches. This is quite naive. From exiftool, it looks for either: - a ‘Bibtex’ field, - a ‘Description’ field,
and compares that to the raw entry’s text.
TODO switch to use a stored hash instead
- Parameters:
path (pathlib.Path)
entry (Entry)
- Return type:
- class bibble.metadata.metadata_writer._Pdf_Update_m
A Mixin for pdf specific metadata manipulation
- _entry_to_exiftool_args(entry) <Unknown>
Extract and format the entry as exiftool args Uses XMP for the metadata under a custom XMP-bib namespace # TODO add exiftool config to bibble
- pdf_finalize(path) <Unknown>
run qpdf –linearize,
on success, delete the original if it exists
- Parameters:
path (pathlib.Path)
- Return type:
None
- pdf_is_modifiable(path) <Unknown>
Use qpdf to test the pdf for encryption or password locking,
- Parameters:
path (pathlib.Path)
- Return type:
- pdf_validate(path) <Unknown>
Validates a pdf using qpdf https://qpdf.readthedocs.io/en/stable/
code 0 for fine, code 2 for errors code 3 for warnings writes to stderr for issues
- Parameters:
path (pathlib.Path)
- Return type:
None
- update_pdf_by_exiftool(path, entry) <Unknown>
exiftool -{tag}=”{content}” {file} https://exiftool.org/
- Parameters:
path (pathlib.Path)
entry (Entry)
- Return type:
None