From c593ecf0659fa521ba5c85feb4695b4032da7d1f Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Tue, 13 Feb 2024 18:02:43 -0500 Subject: [PATCH] added release information --- fedora_schedule.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/fedora_schedule.py b/fedora_schedule.py index 99e9648..7cdecde 100644 --- a/fedora_schedule.py +++ b/fedora_schedule.py @@ -7,6 +7,7 @@ class FedoraSchedule(): def __init__(self, release_version=""): self.release_version = str(release_version) self.schedule_url = "https://fedorapeople.org/groups/schedule" + self.schedule_tasks = self._get_schedule() def _parse_tasks(self, tasks, tasks_so_far=[]): for _tasks in tasks: @@ -18,7 +19,7 @@ class FedoraSchedule(): tasks_so_far.append(_tasks) return tasks_so_far - def get_schedule(self): + 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']) @@ -27,12 +28,32 @@ class FedoraSchedule(): def current_state(self): state = "" today = int(time.strftime("%s", time.gmtime())) - tasks = self.get_schedule() - + tasks = self.schedule_tasks for task in tasks: if int(task['start']) < today and today < int(task ['end']): state = task['name'] - return state + def _get_release(self): + release = {} + release_date = None + tasks = self.schedule_tasks + + for task in tasks: + if 'current_final_target_date' in task['slug']: + release_date = time.strftime('%Y-%m-%d', time.gmtime(int(task['end']))) + release = { + 'name': task['name'], + 'date': release_date + } + + return release + + def release(self): + release = self._get_release() + return f"{release['name']} is {release['date']}" + + def release_date(self): + release = self._get_release() + return release['date']