teachbooks.external_content.bib module¶
Functionality to read write and compare .bib files.
- class teachbooks.external_content.bib.BibEntry(entrytype: str, citekey: str, content: dict[str, str])¶
Bases:
objectContains all information of a bib file entry.
- citekey: str¶
- content: dict[str, str]¶
- entrytype: str¶
- teachbooks.external_content.bib.bib_union(bibs: list[BibEntry], additional_bibs: list[BibEntry])¶
Join two lists of .bib file entries, checking for duplicate keys.
If the citekey exists in both lists, the title is checked. If the title is the same, it is assumed that the reference already exists in the main list, and is skipped silently. If the titles do not match, a warning is given.
- Parameters:
bibs – Main list of bib entries.
additional_bibs – List of additional bib entries you want to add to the main list.
- Returns:
Joined list of .bib file entries.
- teachbooks.external_content.bib.count_brackets(line: str)¶
Returns change in curly bracket nesting level on a line of text.
- teachbooks.external_content.bib.find(citekey: str, bibs: list[BibEntry]) BibEntry¶
Find bib entry by citekey.
- teachbooks.external_content.bib.find_bibfile(repo: Path) Path | None¶
Try to find the references.bib file in the usual locations.
- teachbooks.external_content.bib.merge_bibs(bibfile: Path, repos: list[Path]) list[BibEntry]¶
Merge the book’s .bib file with all external bibs.
Will return an empty list if no reference.bib files are present anywhere.