Client to work with Zenodo API
Project description
zenodopy
Project under active deveopment, not production ready
A Python 3.6+ package to manage Zenodo repositories.
Functions Implemented
.create_project(): create a new project.upload_file(): upload file to project.download_file(): download a file from a project.delete_file(): permanently removes a file from a project.get_urls_from_doi(): returns the files urls for a given doi
Installing
PyPi
pip install zenodopy==0.3.0
GitHub
pip install -e git+https://github.com/lgloege/zenodopy.git#egg=zenodopy
Using the Package
- Create a Zenodo access token by first logging into your account and clicking on your username in the top right corner. Navigate to "Applications" and then "+new token" under "Personal access tokens". Keep this window open while you proceed to step 2 because the token is only displayed once. Note that Sandbox.zenodo is used for testing and zenodo for production. If you want to use both, create for each a token as desribed above.
- Store the token in
~/.zenodo_tokenusing the following command.
# zenodo token
{ echo 'ACCESS_TOKEN: your_access_token_here' } > ~/.zenodo_token
# sandbox.zenodo token
{ echo 'ACCESS_TOKEN-sandbox: your_access_token_here' } > ~/.zenodo_token
- start using the
zenodopypackage
import zenodopy
# always start by creating a Client object
zeno = zenodopy.Client(sandbox=True)
# list project id's associated to zenodo account
zeno.list_projects
# create a project
zeno.create_project(title="test_project", upload_type="other")
# your zeno object now points to this newly created project
# create a file to upload
with open("~/test_file.txt", "w+") as f:
f.write("Hello from zenodopy")
# upload file to zenodo
zeno.upload_file("~/test.file.txt")
# list files of project
zeno.list_files
# set project to other project id's
zeno.set_project("<id>")
# delete project
zeno._delete_project(dep_id="<id>")
Notes
This project is under active development. Here is a list of things that needs improvement:
- more tests: need to test uploading and downloading files
- documentation: need to setup a readthedocs
- download based on DOI: right now you can only download from your own projects. Would be nice to download from
- asyncronous functions: use
asyncioandaiohttpto write async functions. This will speed up downloading multiple files.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zennewpy-0.1.0.tar.gz
(10.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zennewpy-0.1.0.tar.gz.
File metadata
- Download URL: zennewpy-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40e011a5d41db807ebcb1f712f89574f7daae46b1329f09f26e0e20cb31b4a9e
|
|
| MD5 |
326dd9fe144556d5af5b16058b1cb4bf
|
|
| BLAKE2b-256 |
b27d2253f2c82f832434f7896c2a5ffdf6a2298c3e27db0e574d410475acdedc
|
File details
Details for the file zennewpy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: zennewpy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9647d6ce50c21ffe4ac3583f5870d5cfeeff02288bc8a03dbda83f80af858dbb
|
|
| MD5 |
7feefa7766a79f6fdf191406e5be3b19
|
|
| BLAKE2b-256 |
fe88af62b144535f1764ddb3483ae3a4a1d5302d2030c3dcece2b530f60ce8ec
|