First attempt

This commit is contained in:
Stefan Bethke 2025-11-18 19:05:41 +01:00
commit 89677fbeee
22 changed files with 3461 additions and 0 deletions

98
hackertours.py Normal file
View file

@ -0,0 +1,98 @@
"""
Creates a schedule.json from the Hackertours planning Excel.
"""
import math
import sys
from datetime import datetime, timedelta, timezone
import pandas
import pytz
from numpy import nan
import voc.tools
from voc.schedule import Schedule, Event
def create_schedule(sheet_file: str, schedule_file: str):
# global voc.tools.VERSION
voc.tools.VERSION = "0.0.1"
planning_df = pandas.read_excel(sheet_file, sheet_name="Tours")
description_df = pandas.read_excel(sheet_file, sheet_name="Descriptions")
descriptions = {}
for index, row in description_df.iterrows():
d = {}
for k in description_df.keys():
d[k] = description_df[k][index]
descriptions[d['Name']] = d
start = datetime(year=2025, month=12, day=26, tzinfo=pytz.timezone('Europe/Berlin'))
acronym = "ht"
duration = 4
schedule = Schedule.from_template(
title="39C3 Hackertours",
acronym="39c3ht",
year=2025,
month=12,
day=26,
days_count=5,
tz="Europe/Berlin")
# schedule.schedule().version = '1.0'
# Remove reporting rows
for index, row in planning_df.iterrows():
name = row['Tour']
if isinstance(name, float) and math.isnan(name):
planning_df.drop(index=range(index, len(planning_df)), inplace=True)
break
# Sort to make stable
planning_df.sort_values(by=['Tag', 'Am HT-Desk', 'Tour'], inplace=True)
# in the Excel, days start at 0; the event here starts on the 26th. Normally, we would convert the 1-based day to a 0-ased offset from the start day, but here, it's 0-based
for index, row in planning_df.iterrows():
name = row['Tour']
if isinstance(name, float) and math.isnan(name):
break
if name not in descriptions:
continue
start_time = row['Am HT-Desk']
event_start = start + timedelta(days=row['Tag'])
event_start = event_start.replace(hour=start_time.hour, minute=start_time.minute)
event_duration = row['Dauer']
print(f"name={name} day={row['Tag']} start={row['Am HT-Desk']} duration={row['Dauer']}")
guid = voc.tools.gen_uuid('{}-{}-{}'.format(row['Tag'], row['Am HT-Desk'], name))
schedule.add_event(Event({
'id': index,
'guid': guid,
# ('logo', None,
'date': event_start.isoformat(),
'start': event_start.strftime('%H:%M'),
'duration': event_duration.strftime("%M:%S"),
'room': descriptions[name]['Title'],
'slug': voc.tools.normalise_string(f"{name}-{row['Tag']:0.0f}-{row['Am HT-Desk']}".lower()),
'url': descriptions[name]['Link'],
'title': descriptions[name]['Title'],
'subtitle': None,
'track': None,
'type': None,
'language': row['Sprache'],
'abstract': descriptions[name]['Abstract'],
'description': None,
'persons': [],
'links': [
{
'url': descriptions[name]['Link'],
'title': descriptions[name]['Title']
}
]
}))
schedule.export(schedule_file)
if __name__ == "__main__":
create_schedule(sys.argv[1], sys.argv[2])