API

This module describes which functions are intended to be used by users to create papis scripts.

papis.api.clear_lib_cache(lib=None)[source]

Clear cache associated with a library. If no library is given then the current library is used.

Parameters

lib (str) – Library name.

>>> clear_lib_cache()
papis.api.doi_to_data(doi)[source]

Try to get from a DOI expression a dictionary with the document’s data using the crossref module.

Parameters

doi (str) – DOI expression.

Returns

Document’s data

Return type

dict

papis.api.edit_file(file_path, wait=True)[source]

Edit file using the editor key value as a program to handle file_path.

Parameters
  • file_path (str) – File path to be handled.

  • wait (bool) – Wait for the completion of the opener program to continue

papis.api.get_all_documents_in_lib(library=None)[source]

Get ALL documents contained in the given library with possibly.

Parameters

library (str) – Library name.

Returns

List of all documents.

Return type

list

>>> import tempfile
>>> folder = tempfile.mkdtemp()
>>> set_lib_from_name(folder)
>>> docs = get_all_documents_in_lib(folder)
>>> len(docs)
0
papis.api.get_documents_in_dir(directory, search='')[source]

Get documents contained in the given folder with possibly a search string.

Parameters
  • directory (str) – Folder path.

  • search (str) – Search string

Returns

List of filtered documents.

Return type

list

>>> import tempfile
>>> docs = get_documents_in_dir(tempfile.mkdtemp())
>>> len(docs)
0
papis.api.get_documents_in_lib(library=None, search='')[source]

Get documents contained in the given library with possibly a search string.

Parameters
  • library (str) – Library name.

  • search (str) – Search string

Returns

List of filtered documents.

Return type

list

papis.api.get_lib_name()[source]

Get current library, it either retrieves the library from the environment PAPIS_LIB variable or from the command line args passed by the user.

Returns

Library name

Return type

str

>>> get_lib_name() is not None
True
papis.api.get_libraries()[source]

Get all libraries declared in the configuration. A library is discovered if the dir or dirs key defined in the library section.

Returns

List of library names

Return type

list

>>> len(get_libraries()) >= 1
True
papis.api.open_dir(dir_path, wait=True)[source]

Open dir using the file-browser key value as a program to open dir_path.

Parameters
  • dir_path (str) – Folder path to be handled.

  • wait (bool) – Wait for the completion of the opener program to continue

papis.api.open_file(file_path, wait=True)[source]

Open file using the opentool key value as a program to handle file_path.

Parameters
  • file_path (str) – File path to be handled.

  • wait (bool) – Wait for the completion of the opener program to continue

papis.api.pick(options, pick_config={})[source]

This is a wrapper for the various pickers that are supported. Depending on the configuration different selectors or ‘pickers’ are used.

Parameters
  • options (list) – List of different objects. The type of the objects within the list must be supported by the pickers. This is the reason why this function is difficult to generalize for external picker programs.

  • pick_config (dict) – Dictionary with additional configuration for the used picker. This depends on the picker.

Returns

Returns elements of options.

Return type

Element(s) of options

papis.api.pick_doc(documents)[source]

Pick a document from documents with the correct formatting

Documents

List of documents

Returns

Document

papis.api.set_lib_from_name(library)[source]

Set current library, it either sets the library in the environment PAPIS_LIB variable or in the command line args passed by the user.

Parameters

library (str) – Name of library or path to a given library