publi module¶
A program to build, update, export publications
- 
class 
publi.PublicationDatabase(database_file=None, pdf_dir=None, prefix=None)[source]¶ Bases:
objectClass to hold information about publication lists
- 
add_bibdata(entries)[source]¶ Add several entries to the database.
Parameters: entries (str or pybtex.database.BibliographyData. If a string is passed it will be treated as the name of a BibTeX file.) – Entries to add
- 
add_entry(key, entry)[source]¶ Add an entry to the database.
Parameters: - key (str) – Key of the new entry. Will be disambiguated before insertion
 - entry (
pybtex.database.Entry) – Entry to add 
- 
classmethod 
default_comparator(item1, item2)[source]¶ Default comparator for bibliograpyh items.This function will first compare the keys and then check whether both entries have a title field and if so, check whether their values are similar according to a ratio computed with
difflib.SequenceMatcher. Equality is assumed if r>=0.8Parameters: Returns: Whether the two are duplicates or not
Return type: 
- 
find_duplicates(comparator=None)[source]¶ Find suspected duplicates.
Parameters: comparator (function (see default_comparator())) – binary function to determine whether two bib items (of type (str,pybtex.database.Entry)) are identical
- 
iter_entries(predicate=None)[source]¶ Create and iterator for filtering entries.
Parameters: - predicate – Filter function to use. If 
None, all entries will be included. - predicate – function
 
- predicate – Filter function to use. If 
 
- 
populate(database_file, pdf_dir)[source]¶ Collect all bibdata from all files into one big-ass database (self), rekeying the entries. This method will also set
publipy_biburl,publipy_abstracturl, andpublipy_pdfurlattributes on the entries. Pdf files are copied topdf_dir/pdf.Parameters: 
- 
publications_for_member(member)[source]¶ Get all publications the given person is involved in. Currently not implemented
Parameters: member (str or pybtex.database.Person) – Relevant personReturns: Iterator 
- 
publications_for_type(type)[source]¶ Get all publications of the given kind (book, article, inproceedings..).
Parameters: type (str) – Desired type Returns: Iterator 
- 
publications_for_year(min_year, max_year)[source]¶ Get all publications between two years (inclusive)
Parameters: Returns: Iterator
Raises: ValueError if
min_year >= max_year
- 
save()[source]¶ Serialize self to pickled file named
db.pcklfor caching and update thePublicationDatabase.database_filewith all entries. Also, directoriesabstract,pdfandbibare created underPublicationDatabase.prefixwhich are filled with one file per key each – one for a BibTeX file with the single entry, one text file for the abstract (if present in the entry) and one pdf file (if a pdf named like the entry’s key was found in thepdf_dirparameter passed toPublicationDatabase.populate())
- 
 
- 
publi.add(args)[source]¶ Add item(s) to the database. Uses the
entriesfield from the arguments.Parameters: args ( argparse.Namespace) – Command line arguments obtained viaargparse.ArgumentParser’sargparse.ArgumentParser.parse_args()method.
- 
publi.build(args)[source]¶ Build and save a
PublicationDatabasefrom the arguments passed.Parameters: args ( argparse.Namespace) –argparse.Namespaceobject obtained viaargparse.ArgumentParser’sargparse.ArgumentParser.parse_args()method.
- 
publi.disambiguate(key, keyset)[source]¶ Disambiguate key over set of keys by successively appending more alphanumeric numbers.
- 
publi.filtered_entries(database, args)[source]¶ Get a
PublicationDatabasecontaining only selected entries. Will read out theperson,expr, andmytypefilters from the arguments. Only entries meeting all criteria are selected.Parameters: - database (
PublicationDatabase) – Database of publications - args (
argparse.Namespace) – Command line arguments 
- database (
 
- 
publi.generate_key_bibtool(entry)[source]¶ Generate a key like bibtool would create with the following options
key.base=lowerkey.format=short
Parameters: entry (pybtex.database.Entry) – Entry to key Returns: The new key Return type: str 
- 
publi.generate_key_swe(entry)[source]¶ Create a new bibtex key for the given entry in the format desired by the group leader. The format is
<first author>:<first title word>:yy. Stop words (non-significant ones such as articles) are ignored. Missing fields are empty.Parameters: entry (pybtex.database.Entry) – Bibliography item to key Returns: The new key Return type: str 
- 
publi.generate_suffix(key, keyset, current_suffix='')[source]¶ Generate a key suffix for disambiguation. The resulting key will be unique with respect to keyset. Works by appending successively more alphanumeric characters (
key -> key.a -> key.b -> ... -> key.ab)Parameters: Returns: The new key
Return type: 
- 
publi.group_entries_by_key(entries, sorter, group_name_dict=None)[source]¶ Sort set of entries into groups depending on the value of sorter. Returns
dictwhere keys are the different values of the sorter field occurring across the set of entries.Parameters: - entries (list) – Iterable of 
pybtex.database.Entryobjects - sorter (str) – Name of the field to sort on
 - group_name_dict (dict) – Dict to map the group names to something else
 
Returns: Dictionary mapping field value to list of entries with that value
Return type: - entries (list) – Iterable of 
 
- 
publi.list_entries(args)[source]¶ Render database to format and write to file. See
render()Parameters: args ( argparse.Namespace) – Command line arguments
- 
publi.main()[source]¶ Process user commands. The program has several subcommands. Run with –help for full details.
- 
publi.make_plain(text)[source]¶ Detexify and asciify text
Parameters: text (str) – Text to make plain Returns: Text with all LaTeX sequences rendered to text and unicode characters replaced Return type: str 
Print all persons found in the database. Can be authors or editors (in spite of the name)
- 
publi.read_bibfile(filename)[source]¶ Parse
pybtex.database.BibliographyDatafrom BibTeX file.Parameters: filename (str) – Name of the BibTeX file Returns: The parsed data Return type: pybtex.database.BibliographyData
- 
publi.render(args)[source]¶ Render publication database into various formats. Supported are
bib,html,texandpdf(currently unimplemented)Parameters: args ( argparse.Namespace) – Command line argumentsReturns: Rendered database Return type: str Raises: ValueError if unknown format passed 
- 
publi.render_to_html(publications, args)[source]¶ Render publication database to html. Optionally complete or as embeddable fragment.
Parameters: - publications (
PublicationDatabase) – Publications to render - args (
argparse.Namespace) – Command line arguments 
Returns: Rendered database
- publications (
 
- 
publi.render_to_tex(publications, args)[source]¶ Render publication database to latex. Optionally complete or as embeddable fragment.
Parameters: - publications (
PublicationDatabase) – Publications to render - args (
argparse.Namespace) – Command line arguments 
Returns: Rendered database
- publications (