API, nástroje a utiltky pre prácu a integráciu s Kockatým Kalendárom pre Python.
Inštalácia
Základná verzia tejto knižnice sa dá nainštalovať pomocou pip:
pip install kockatykalendar
Ak plánujete používať JSON API Kockatého Kalendára, použite:
pip install kockatykalendar[api]
Ak plánujete použiť Django integráciu pre Kockatý Kalendár, použite:
pip install kockatykalendar[django]
Ak chcete obe veci, nainštalujte si kockatykalendar[api,django].
Udalosti v kalendári
kockatykalendar poskytuje Python reprezentáciu udalostí z Kockatého Kalendára. Možno ju využiť na prácu s udalosťami v kalendári ale aj ich tvorbu.
from datetime import date
from kockatykalendar.events import Event, EventType, EventScience, EventContestant
event = Event()
event._id = "ksp-sus-1"
event.name = "KSP sústredenie"
event.type = EventType.SUSTREDENIE
event.sciences = [EventScience.INF]
event.date.start = date(2020, 12, 13)
event.date.end = date(2020, 12, 20)
event.contestants.min = EventContestant(EventContestant.SchoolType.STREDNA, 1)
event.contestants.min = EventContestant(EventContestant.SchoolType.STREDNA, 4)
event.places = ["TBD"]
event.organizers = ["trojsten"]
event.link = "https://ksp.sk/akcie/sustredenia/"
print(event.to_json())
event = Event.from_json(...)
API
Súčasťou kockatykalendar je aj prístup do JSON API Kockatého Kalendára.
from kockatykalendar.api import get_events, get_current_dataset, get_available_datasets
get_available_datasets()
# [
# Dataset(start_year=2020,
# end_year=2021,
# school_year="2020/2021",
# filename="2020_21.json"),
# ...
# ]
get_current_dataset()
# Dataset(start_year=2020,
# end_year=2021,
# school_year="2020/2021",
# filename="2020_21.json")
get_events(dataset) # Dataset môže byť: Dataset, filename alebo celá URL.
# [
# Event,
# ...
# ]
Django integrácia
Zatiaľ iba draft, ešte pracujeme na všetkých detailoch implementácie.
Organizátori môžu poskytovať svoje udalosti do Kockatého Kalendára aj prostredníctvom endpointu na ich stránkach. V prípade Djanga si stačí zadefinovať jeden alebo viac generátorov, ktoré budú tvoriť obsah kalendára:
from kockatykalendar.generators import CalendarGenerator
from kockatykalendar.events import Event, EventType, EventScience
class NaseSeminareGenerator(CalendarGenerator):
def items(self):
return Seminar.objects.all()
def event(self, item):
return Event(
_id="seminar-%d" % item.id,
name=item.name,
sciences=[EventScience.MAT],
type=EventType.SEMINAR,
oragnizers=["trojsten"],
places=["online"],
date=Event.Dates(start=item.start, end=item.end)
)
Generátor nie je závislý na Djangu, možno ho použiť aj s inými frameworkami, pokiaľ sa dodrží formát výstupu. Následne treba pridať view do URLconf-u:
from kockatykalendar.django import kockatykalendar_json
path("kkalendar.json", kockatykalendar_json, {"generators": [NaseSeminareGenerator()]})
Metadata
Release files for kockatykalendar 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kockatykalendar-0.1.2.tar.gz | 6.3 kB | Without provenance | Details for kockatykalendar-0.1.2.tar.gz |
Release files / kockatykalendar-0.1.2.tar.gz
| Download URL | kockatykalendar-0.1.2.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36300cd44b4422dcc91f944e194f65bdc711ccc2efe32b26ebcf5950e05aac14
|
|
BLAKE2b-256 checksum How to use checksums |
bd3888bb2afc72c72e4a09067aed4e3580636ced3b3a1edec5a342770cdaa50c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.7
|
Security for kockatykalendar 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.