bibpy v1.0.1
Python library for parsing bib(la)tex files and manipulating entries.
- Automatic conversion of entry fields to and from appropriate Python types
- Requirements-checking for entry fields
- String variable expansion and unexpansion
- Crossreference and xdata inheritance
- Accompanying tools
Installation
pip install bibpy
Quickstart
>>> import bibpy
>>> result = bibpy.read_file('references.bib') # Read a bib file
>>> entries = result.entries
>>> print len(entries)
6
>>> print entries[0].author
'D. J. Power'
>>> print entries[0].bibkey
'2006_power'
>>> print entries[0].bibtype
'online'
>>> print entries[0].valid('bibtex')
True # Entry is a valid bibtex entry
>>> print entries[0].valid('biblatex')
False # But is not a valid biblatex entry (missing field 'date' or 'year')
>>> print entries[0].aliases('bibtex')
[]
>>> print entries[0].aliases('biblatex')
['electronic', 'www']
>>> bibpy.write_file('references.bib', entries)
See the examples
folder for more usage examples or read the
tutorial.
Tools
bibpy
also comes with three tools that are installed as runnable scripts.
-
bibformat
: Clean up, format and align references -
bibgrep
: Find and filter references using a simple query language -
bibstats
: Display statistics about bib files
All three tools are described in more detail in the tutorial.