Package: pyDeadlineAPI
pyDeadlineAPIThis is the first implemention of theDeadlineAPIfor 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:EndpointDeadlineObjectLocationContactInstallYou can easily install pyDeadlineAPI via pip:pip install pyDeadlineAPIThe APIIn 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 atdirectory.deadlineapi.org/directory.json:importdeadlineapidirectory=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:importdeadlineapideadlineapi.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)TheloadDirectly=True(default) makes sure that the endpoints get loaded directly and provides you with a list ofEndpoints. This may take some time. You can also setloadDirectly=False. In this case you will get a list ofDirectoryItems instead. You can useendpoint = directoryitem.load()to load the endpoint afterwards.EndpointsEndpoints represent the endpoints of the api. You can use all the fields specified in the JSON schema. E.g.:importdeadlineapidirectory=deadlineapi.Loader.load_directory_by_url(loadDirectly=True)forendpointindirectory:print(f"Endpoint is compatible to:{endpoint.api_compatibility}")print(f"Deadlines provide by{endpoint.name}:")fordinendpoint.deadlines:print(f"{d.name}:{d.deadline}")In the following table we list all the functionality that is on top of the API fields.NameDescriptionendpointnamekey in the directory fileendpointurlvalue (url) in the directory fileNote further that you can also load endpoints directly. E.g.importdeadlineapideadlineapi.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 theJSON schemaand 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 theschema repository.DirectoryItemA DirectoryItem is simple the representation of a key-value pair of the directory. It only hast two fields:NameDescriptionendpointnamekey in the directory fileendpointurlvalue (url) in the directory fileYou can useendpoint = directoryitem.load()to load it and turn it into anEndpointwith all the deadline and fields attached. This will also setendpointnameandendpointurlin the Endpoint object.DeadlineObjectThe 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:NameDescriptiondays_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 objectLocationThis class just wraps the location. It provides the following additional methods:NameDescriptionto_str()Provides the location as string, e.g.virtualorGermany, KarlsruheContactThe last class is Concat. This also provides atoStr()function:NameDescriptionto_str()Provides the contact as string, e.g.info@kit.edu, @kitdeContributeClone this repo and runpython3-mvenvvenvsourcevenv/bin/activate
pip-rrequirements.txtWe use the GitFlow method to organize our branches. Please work with PullRequests.CreditsMany many credits forSpaceAPI, 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!