2018-07-13 00:03:33 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
from glob import glob
|
2018-08-15 00:49:06 +02:00
|
|
|
|
2018-07-13 00:03:33 +02:00
|
|
|
import pytz
|
2018-08-15 00:49:06 +02:00
|
|
|
import icalendar
|
2018-07-13 00:03:33 +02:00
|
|
|
|
2018-08-15 00:49:06 +02:00
|
|
|
|
|
|
|
cals = []
|
|
|
|
merged = icalendar.Calendar()
|
2018-07-13 00:03:33 +02:00
|
|
|
merged.add('prodid', '-//CCCB Calendar Generator//berlin.ccc.de//')
|
2018-08-15 00:49:06 +02:00
|
|
|
merged.add('version', '2.0')
|
2018-07-13 00:03:33 +02:00
|
|
|
|
2018-08-15 00:49:06 +02:00
|
|
|
for icsfilestr in glob('public/*/**/*.ics', recursive=True):
|
2018-07-13 00:03:33 +02:00
|
|
|
with open(icsfilestr, 'r') as icsfile:
|
2018-08-15 00:49:06 +02:00
|
|
|
print('Importing', icsfilestr)
|
2018-07-13 00:03:33 +02:00
|
|
|
cals.append(icalendar.Calendar.from_ical(icsfile.read()))
|
|
|
|
|
|
|
|
for cal in cals:
|
|
|
|
for e in cal.subcomponents:
|
|
|
|
merged.add_component(e)
|
|
|
|
|
2018-08-15 00:49:06 +02:00
|
|
|
outfile = 'static/all.ics'
|
2018-07-13 00:03:33 +02:00
|
|
|
with open(outfile, 'wb') as f:
|
2018-08-15 00:49:06 +02:00
|
|
|
print(f'writing to {outfile}...')
|
2018-07-13 00:03:33 +02:00
|
|
|
f.write(merged.to_ical())
|
2018-08-15 00:49:06 +02:00
|
|
|
|