Handle adding dates to talks that have the same title
This commit is contained in:
parent
2e00a2dc41
commit
6922b1bf11
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -37,12 +38,14 @@ def process_schedule(filename: str, short_name: str) -> None:
|
||||||
|
|
||||||
print((conf.short_name, conf.title))
|
print((conf.short_name, conf.title))
|
||||||
|
|
||||||
|
by_title = collections.defaultdict(list)
|
||||||
|
|
||||||
root = lxml.etree.parse(filename).getroot()
|
root = lxml.etree.parse(filename).getroot()
|
||||||
for day in root.findall(".//day"):
|
for day in root.findall(".//day"):
|
||||||
day_index_str = day.get("index")
|
day_index_str = day.get("index")
|
||||||
# assert day_index_str is not None
|
# assert day_index_str is not None
|
||||||
# day_index = int(day_index_str)
|
# day_index = int(day_index_str)
|
||||||
print("day", day_index_str)
|
# print("day", day_index_str)
|
||||||
for event_element in day.findall(".//event"):
|
for event_element in day.findall(".//event"):
|
||||||
title = read_field(event_element, "title")
|
title = read_field(event_element, "title")
|
||||||
start = read_field(event_element, "start")
|
start = read_field(event_element, "start")
|
||||||
|
@ -55,19 +58,35 @@ def process_schedule(filename: str, short_name: str) -> None:
|
||||||
dt = datetime.datetime.fromisoformat(d + " " + start)
|
dt = datetime.datetime.fromisoformat(d + " " + start)
|
||||||
|
|
||||||
q = model.Event.query.filter_by(title=title, conference=conf)
|
q = model.Event.query.filter_by(title=title, conference=conf)
|
||||||
if q.count() != 1:
|
if q.count() < 2:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
by_title[title].append((dt, read_field(event_element, "abstract")))
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
event = q.one()
|
event = q.one()
|
||||||
event.event_date = dt
|
event.event_date = dt
|
||||||
event.abstract = read_field(event_element, "abstract")
|
event.abstract = read_field(event_element, "abstract")
|
||||||
|
|
||||||
print(start, title)
|
print(start, title)
|
||||||
|
|
||||||
|
for title, events in by_title.items():
|
||||||
|
q = model.Event.query.filter_by(title=title, conference=conf).order_by(
|
||||||
|
model.Event.id
|
||||||
|
)
|
||||||
|
if q.count() != len(events):
|
||||||
|
continue
|
||||||
|
print((short_name, title))
|
||||||
|
for event, (dt, abstract) in zip(q, events):
|
||||||
|
print(" ", event.id, dt)
|
||||||
|
event.event_date = dt
|
||||||
|
event.abstract = abstract
|
||||||
|
|
||||||
|
|
||||||
for f in os.scandir(schedules_loc):
|
for f in os.scandir(schedules_loc):
|
||||||
if f.is_dir():
|
if f.is_dir():
|
||||||
continue
|
continue
|
||||||
print(f.name)
|
print(f.name)
|
||||||
process_schedule(f.path, f.name)
|
process_schedule(f.path, f.name)
|
||||||
# database.session.commit()
|
database.session.commit()
|
||||||
|
|
Loading…
Reference in a new issue