Skip to content

Commit

Permalink
chore: fix misc issues / cleanup / comments
Browse files Browse the repository at this point in the history
  • Loading branch information
saerdnaer committed Dec 27, 2024
1 parent e0b0c59 commit 4b27c24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 8 additions & 7 deletions voc/c3data.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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 + ': ')
Expand Down Expand Up @@ -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__':
Expand Down
5 changes: 5 additions & 0 deletions voc/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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 = []
Expand Down

0 comments on commit 4b27c24

Please sign in to comment.