BibTexFile module

BibTexFile class

class biblib.BibTexFile(filename)[source]

This is the BibTeX file class.

It is derived from the BibDB class including a reader db_from_file() and writer db_to_file() function. It also supports the with statement.

Parameters:filename (str) – input BibTeX file
Returns:BibTeX file object
Return type:BibTexFile
__init__(filename)[source]

Initialize self. See help(type(self)) for accurate signature.

reload()[source]

Reload the BibTeX file.

Note

The database will overwritten and all changes will get lost!

save()[source]

Save all changes to the BibTeX file.

_backup()[source]

Backup a file and its previous backups.

has_changed()[source]

Check if database have changed (since last saving).

Returns:True | False
Return type:bool
close()[source]

Alternative to the BibTexFile.save() function.

BibTexFileSet class

class biblib.BibTexFileSet[source]
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

keys()[source]

Returns a list of alias defined in the set.

Returns:list of alias
Return type:list
values()[source]

Returns a list of BibTexFile object stored in the set.

Returns:list of BibTexFile object
Return type:list
items()[source]

Returns a list of sets containing alias/ BibTexFile object.

Returns:list of sets alias/ BibTexFile object
Return type:list
__getitem__(key)[source]

Returns the BibTexFile object with the given alias in the set.

Parameters:key (str) – alias
Returns:BibTeX file object
Return type:BibTexFile
Raises:NameError – if alias did not exist in set
__setitem__(key, value)[source]

Add/set a BibTeX file object with an alias to the set.

Parameters:
  • key (str) – alias
  • value (BibTexFile) – BibTeX file object
Raises:
  • TypeError – if value is not of a valid object type
  • KeyError – if alias already exists in set
__delitem__(key)[source]

Deletes a BibTeX file object from the set.

Parameters:key (str) – alias
Raises:NameError – if citation-key did not exist in database
has_doi(doi)[source]

Check if a given DOI is known.

Parameters:doi (str) – digital object identifier (DOI)
Returns:True | False
Return type:bool
dois

Returns a dictionary with doi as key and [alias, citation-key] list as value.

ckeys

Returns a dictionary with citation-key as key and alias as value.

__weakref__

list of weak references to the object (if defined)