From 4b27c2415912390ab2190d7548ed561723c70b33 Mon Sep 17 00:00:00 2001 From: Andreas Hubel Date: Fri, 27 Dec 2024 14:43:11 +0100 Subject: [PATCH] chore: fix misc issues / cleanup / comments --- voc/c3data.py | 15 ++++++++------- voc/schedule.py | 5 +++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/voc/c3data.py b/voc/c3data.py index 4e081a5..c984a02 100644 --- a/voc/c3data.py +++ b/voc/c3data.py @@ -1,19 +1,18 @@ import argparse from os import getenv, path import json -import git from gql import Client, gql from gql.transport.aiohttp import AIOHTTPTransport from gql.transport.exceptions import TransportQueryError -from voc import logger - try: from .schedule import Schedule from .event import Event from .room import Room from .tools import load_json, write + from . import logger + except ImportError: import sys @@ -22,6 +21,8 @@ from schedule import Schedule, Event from room import Room from tools import load_json, write + from voc import logger + transport = AIOHTTPTransport( @@ -171,7 +172,7 @@ def __init__(self, schedule: Schedule, create=False): if not result['conference']: raise "Please create conference in target system using --create" self.conference_id = result['conference']['id'] - + self.room_ids = {x['name']: x['guid'] for x in result['conference']['rooms']['nodes']} # check for new/updated rooms @@ -194,7 +195,7 @@ def upsert_event(self, event: Event): def depublish_event(self, event_guid): remove_event(event_guid) - def process_changed_events(self, repo: git.Repo, options): + def process_changed_events(self, repo: 'Repo', options): changed_items = repo.index.diff('HEAD~1', 'events') for i in changed_items: write(i.change_type + ': ') @@ -223,9 +224,9 @@ def upsert_schedule(schedule: Schedule, create=False): def test(): # schedule = Schedule.from_url('https://fahrplan.events.ccc.de/camp/2019/Fahrplan/schedule.json') - schedule = Schedule.from_file('eh21/everything.schedule.json') + schedule = Schedule.from_file('38C3/everything.schedule.json') - upsert_schedule(schedule, create=False) + upsert_schedule(schedule, create=True) if __name__ == '__main__': diff --git a/voc/schedule.py b/voc/schedule.py index ddc4919..b60910b 100644 --- a/voc/schedule.py +++ b/voc/schedule.py @@ -347,7 +347,11 @@ def add_room_with_events(self, day: int, target_room, data, origin=None): else: target_day_rooms[target_room] = data + + # TODO this method should work woth both room key and room guid, + # but currently it only works with room name def remove_room(self, room_key: str): + # if room key is a name, remove it directly from the room list if room_key in self._room_ids: del self._room_ids[room_key] @@ -393,6 +397,7 @@ def foreach_event(self, func, *args): result = func(event if isinstance(event, Event) else Event(event), *args) if result: out.append(result) + return out def foreach_event_raw(self, func, *args): out = []