commit 2076cf2ce95483260018932fe6f835fa6c090201 Author: Mark McIntyre Date: Mon Feb 12 20:01:16 2024 -0500 initial load diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76d72de --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +.py[co] + diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fedora_schedule.py b/fedora_schedule.py new file mode 100644 index 0000000..99e9648 --- /dev/null +++ b/fedora_schedule.py @@ -0,0 +1,38 @@ +import time +import requests +import json + + +class FedoraSchedule(): + def __init__(self, release_version=""): + self.release_version = str(release_version) + self.schedule_url = "https://fedorapeople.org/groups/schedule" + + def _parse_tasks(self, tasks, tasks_so_far=[]): + for _tasks in tasks: + if _tasks['_level'] < 3: + self._parse_tasks(_tasks['tasks'], tasks_so_far) + else: + if 'tasks' in _tasks.keys(): + self._parse_tasks(_tasks['tasks'], tasks_so_far) + tasks_so_far.append(_tasks) + return tasks_so_far + + def get_schedule(self): + release_schedule_url = f"{self.schedule_url.format(self.release_version)}/f-{self.release_version}/f-{self.release_version}-key.json" + schedule_json = json.loads(requests.get(release_schedule_url).content) + tasks = self._parse_tasks(schedule_json['tasks']) + return tasks + + def current_state(self): + state = "" + today = int(time.strftime("%s", time.gmtime())) + tasks = self.get_schedule() + + for task in tasks: + if int(task['start']) < today and today < int(task ['end']): + state = task['name'] + + return state + +