- Use syntax compatible with Python
3.5+
. - Use docstrings with Sphinx in mind.
- Follow the PEP8 style guide
- Try and run tests locally before submitting a new PR.
For development, consider creating a new virtual environment (with any prefered method, e.g. venv). All development packages can be installed with
python -m pip install -e '.[develop]'
To run the tests, just use pytest
. Some helpful wrappers are given in the
Makefile
(see make help
), e.g. to run the tests
make test
which runs the full test suite and doctests for papis
. To run the tests exactly
as they are set up on the Github Actions CI use
make ci-install
make ci-test
The docs can be generated with
make doc
You can open issues in the GitHub issue tracker.
The versioning scheme generally follows semantic versioning. That is, we
have three numbers, A.B.C
, where:
A
changes on a rewriteB
changes when major configuration incompatibilities occurC
changes with each release (bug fixes..)
To add a new main option:
- Add a default value in
defaults.py
in thesettings
dictionary. - Document the option in
doc/source/default-settings.rst
. Try to answer the following questions:- What is it?
- Where is it used?
- What type should it be?
- What values are allowed? (default values are added automatically)
The setting is now accessible with papis.config.get("myoption")
or through the command-line interface papis config myoption
.
To add a new option in a custom section (or generally with a common prefix)
- Call
papis.config.register_default_settings
with a dictionary{"section": {"option1": "value", ...}}
. - Document the option in a similar fashion to above
The setting can now be accessed with papis.config.get("section-option1")
or papis.config.get("option1", section="section")
.
Can add scripts for everyone to share to the folder examples/scripts
in the
repository. These scripts will not be shipped with papis, but they are there
for other users to use and modify.
An importer is used to get data from a file or service into papis
. For example,
see the arXiv importers in arxiv.py
. To add a new importer
- Create a class that inherits from
papis.importer.Importer
. - Implement the
Importer.match
method, which is used to check if a given URI can be handled by the importer. - Implement the
Importer.fetch
method, that gets the data. This method should set theImporter.ctx
attribute to contain the extracted information. - (Optional) Instead of the
fetch
method, you can also implement thefetch_data
and / orfetch_files
methods separately.
The importer is then registered with papis
by adding it to setup.py
. In the
entry_points
argument under "papis.importer"
add
myimporter=papis.myservice:Importer
or see the existing examples.
The difference between a downloader and an importer in papis
is largely
semantic. Downloaders are mostly meant to scrape websites or download files
from a remote location. They can be implemented in a very similar way:
- Create a class that inherits from
papis.downloaders.Downloader
. - Implement the
Downloader.match
method, which generally checks if a given URI matches a website URL. - (Optional) Implement the
Downloader.get_data
method, which returns a dictionary. - (Optional) Implement the
Downloader.get_bibtex_url
method to return an URL from which a BibTeX file can be downloaded. This is then parsed and merged automatically. - (Optional) Implement the
Downloader.get_document_url
method to return an URL from which a document (e.g. PDF file) can be downloaded.
The downloader can then be added to the "papis.downloader"
key in setup.py
,
similarly to an importer.