API

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

papis.api.clear_lib_cache(lib: Optional[str] = None)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: str)Dict[str, Any][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: str, wait: bool = True)None[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: Optional[str] = None)List[papis.document.Document][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: str, search: str = '')List[papis.document.Document][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: Optional[str] = None, search: str = '')List[papis.document.Document][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()str[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()List[str][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: str, wait: bool = True)None[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: str, wait: bool = True)None[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.set_lib_from_name(library: str)None[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