Git Product home page Git Product logo

py2zenodo's Introduction

PyPI version Code style: black Imports: isort

py2zenodo

A Python wrapper for Zenodo REST API

Installation

We use Poetry to manage this package. Run the following command at the project root directory to install py2zenodo.

poetry install

Then, you can activate the interactive shell environment by

poetry shell

Use cases

Uploading files

Using the CLI

Upload a single file to Zenodo (to be published).

py2zenodo <path_to_file> --token <your_zenodo_api_token>

Upload multiple files to Zenodo sandbox (to be published).

py2zenodo <path_to_file1> <path_to_file2> --token <your_zenodo_sandbox_api_token> --sandbox

Using the API

from py2zenodo import Deposition

# Initialize a deposition for Zenodo sandbox using token information
depo = Deposition(access_token=your_token, sandbox=True)

# Create a new deposition and upload a file
depo.create_new_depo()
depo.upload_file(path_to_file)

Getting record information

For all examples below, we will use the Zenodo record 1145370 that was created for demonstration and testing purposes for py2zenodo.

Getting record information using the record identifier

from py2zenodo import Record

# Load information about a particular record given the record id
# Note: the sandbox option indicates that this is a sandbox record (https://sandbox.zenodo.org).
# For ordinary Zenodo record, set sandbox=False, or simply ignore this option.
rec = Record("1145370", sandbox=True)

# Print some key information about this record
print(rec.title)  # title of this record
print(rec.doi)  # doi of this record
print(rec.latest_link)  # link to the latest version of this record
print(rec.latest_recid)  # record id of the latest version of this record
print(rec.files)  # information about available files in this record

# Show all information associated with the record
print(rec.raw)  # alternatively, use `print(rec.show())` to print nicely formatted json

All available properties for Record:

  • conceptdoi
  • conceptrecid
  • doi
  • files
  • id
  • latest_link
  • latest_recid
  • links
  • metadata
  • title
  • raw

Querying records given a query string

from py2zenodo import Records

# Query records with a query string
recs = Record("py2zenodo", sandbox=True)

# Print information about the records obtained from the query
print(rec.titles)
print(rec.dois)

# Get a particular record by indexing
rec = recs[0]

All available properties for Records:

  • conceptdois
  • conceptrecids
  • dois
  • ids
  • records
  • titles

Getting all versions of a particular record

from py2zenodo import Record, Records

# Load a record
rec = Record("1145373")

# Load all versions of that record by using the concept record identifier
recs = Records(rec.conceptrecid)

py2zenodo's People

Contributors

dependabot[bot] avatar remylau avatar

Watchers

 avatar

py2zenodo's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.