Skip to main content

Access DeadlineAPI directories or endpoint directly

Project description

pyDeadlineAPI

This is the first implemention of the DeadlineAPI for python. It implement the whole functionality of the api plus some additional features. It also runs extensive validity checks before loading successfully loading a file.

The following classes are provided:

  • Endpoint
  • DeadlineObject
  • Location
  • Contact

Install

You can easily install pyDeadlineAPI via pip:

pip install pyDeadlineAPI

The API

In this section we describe how the API works.

How to load a directory?

Loading a directory is easy. You can use the following code to load the default directory at directory.deadlineapi.org/directory.json:

import deadlineapi
directory = deadlineapi.Loader.load_directory_by_url(loadDirectly=True)

Alternatively you can load from a specific url, a string or a local file on your computer/server:

import deadlineapi
deadlineapi.Loader.load_directory_by_url("https://directory.deadlineapi.org/directory.json",loadDirectly=True)
deadlineapi.Loader.load_directory_by_string("{ "endpointname": "url" }",loadDirectly=True)
deadlineapi.Loader.load_directory_by_path(os.path.join("my","path"),loadDirectly=True)

The loadDirectly=True (default) makes sure that the endpoints get loaded directly and provides you with a list of Endpoints. This may take some time. You can also set loadDirectly=False. In this case you will get a list of DirectoryItems instead. You can use endpoint = directoryitem.load() to load the endpoint afterwards.

Endpoints

Endpoints represent the endpoints of the api. You can use all the fields specified in the JSON schema. E.g.:

import deadlineapi
directory = deadlineapi.Loader.load_directory_by_url(loadDirectly=True)
for endpoint in directory:
    print(f"Endpoint is compatible to: {endpoint.api_compatibility}")
    print(f"Deadlines provide by {endpoint.name}:")
    for d in endpoint.deadlines:
        print(f"{d.name}: {d.deadline}")

In the following table we list all the functionality that is on top of the API fields.

Name Description
endpointname key in the directory file
endpointurl value (url) in the directory file

Note further that you can also load endpoints directly. E.g.

import deadlineapi
deadlineapi.Loader.load_endpoint_by_string(s)
deadlineapi.Loader.load_endpoint_by_path(path)
deadlineapi.Loader.load_endpoint_by_url(url)

Endpoints get automatically validated against the JSON schema and other requirements, like url in url field, emails in email field and so on. If you think that something is wrong with the schema files please discuss in the schema repository.

DirectoryItem

A DirectoryItem is simple the representation of a key-value pair of the directory. It only hast two fields:

Name Description
endpointname key in the directory file
endpointurl value (url) in the directory file

You can use endpoint = directoryitem.load() to load it and turn it into an Endpoint with all the deadline and fields attached. This will also set endpointname and endpointurl in the Endpoint object.

DeadlineObject

The DeadlineObject correspond to the individual deadlines. They also got all field provided by API.

import deadlineapi
directory = deadlineapi.Loader.load_directory_by_url()
for endpoint in directory:
        for d in endpoint.deadlines:
                print(f"{d.name}: {d.deadline} ({d.daysleft()}d)")

Note the DeadlineObject also provides some additional functionality:

Name Description
days_left() How many (full) days are left until the deadline.
hours_left() How many (full) hours are left until the deadline.
minutes_left() How many (full) minutes are left until the deadline.
countdown() How much time is left in a useful format (string)
timediff() Provides the time diff as python object

Location

This class just wraps the location. It provides the following additional methods:

Name Description
to_str() Provides the location as string, e.g.virtual or Germany, Karlsruhe

Contact

The last class is Concat. This also provides a toStr() function:

Name Description
to_str() Provides the contact as string, e.g.info@kit.edu, @kitde

Contribute

Clone this repo and run

python3 -m venv venv
source venv/bin/activate
pip -r requirements.txt

We use the GitFlow method to organize our branches. Please work with PullRequests.

Credits

Many many credits for SpaceAPI, who are the ultimative inspiration for this project also provided a lot of the code. E.g. our website is completely adapted by theirs. THANKS!

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

pyDeadlineAPI-0.0.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

pyDeadlineAPI-0.0.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pyDeadlineAPI-0.0.0.tar.gz.

File metadata

  • Download URL: pyDeadlineAPI-0.0.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.5.0.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pyDeadlineAPI-0.0.0.tar.gz
Algorithm Hash digest
SHA256 f90ae27f64d4e07a8e79e928ad846adc3ed70a4004d9d5d1af91ee82442df980
MD5 8e626cac70d4aa43bf9ccac3ed723628
BLAKE2b-256 cc31ed4e9bfefe5c593e6701bee369b5054dbcdca65af482bc931e9308e6cbb1

See more details on using hashes here.

File details

Details for the file pyDeadlineAPI-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyDeadlineAPI-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.5.0.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pyDeadlineAPI-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4896c5e51ce1bcdad42533afc44d9ed98565f9f5193b105d530cbcc1d76746a2
MD5 4da696e0a7bddd641875564973a24099
BLAKE2b-256 eaecacf596d7ab31360882abc53bec70ef23036408e2314c1524229608c9f468

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page