Commit d381e452 authored by PizZaKatZe's avatar PizZaKatZe

Include session end times in printout

parent c25e474b
......@@ -25,7 +25,7 @@ from sys import stdout
from jht_flyergen.engine import fetch_data, render, generate_tex, process_sessions, read_data
DEFAULT_URL = 'https://events.ccc.de/congress/2019/wiki/index.php/Special:Ask/cl:YzpVT9tKxFAM_KKaouzLQl5ERH1QYb8gp03t2Z5LSVJK_XrTdRcUcplhhjAZqmQyPGstkGKOhofWQZmQUoKRqWdR1LGuoEzSjYkCJ3w7fbxDl0hdq2IUEjf37RqneMOa1wuEXUeo4oeQtIM6DMqGLTSHR69XdfNQxecUez0eTRZuDk9e0Dw87_1Cu6dn7STOFmvBP_hm-pTasSr3bg2bD8_GOaQNq3xRid9X5f9RXUINZ-7s7sqNxHxbzIynnUCmWH6fhlnYbJslFsM9JizFg9DMF_YD' # pylint: disable=line-too-long
DEFAULT_URL = 'https://events.ccc.de/congress/2019/wiki/index.php/Special:Ask/format%3Djson/limit%3D128/link%3Dall/headers%3Dshow/searchlabel%3DJSON/class%3Dsortable-20wikitable-20smwtable/sort%3D/order%3Dasc/offset%3D0/-5B-5BCategory:Session-5D-5D-20-5B-5BIs-20for-20kids::true-5D-5D/-3FHas-20description%3Ddescription/-3FHas-20subobject.Has-20session-20location%3Dlocation/-3FHas-20subobject.Has-20start-20time%3Dstarts/-3FHas-20subobject.Has-20end-20time%3Dends/mainlabel%3D/prettyprint%3Dtrue/unescape%3Dtrue' # pylint: disable=line-too-long
def parse_arguments(args):
"""Parses command-line arguments.
......
......@@ -70,7 +70,7 @@ def process_sessions(sessions: List[Dict], day: int) -> List[Dict]:
def is_correct_date(start: Dict) -> bool:
return datetime.fromtimestamp(int(start['timestamp'])).day == day
def relevant(session: Dict) -> bool:
return bool(list(filter(is_correct_date, session['printouts']['Start'])))
return bool(list(filter(is_correct_date, session['printouts']['starts'])))
sessionss = [transform_session(s, day) for s in sessions if relevant(s)]
sessions = [s for ss in sessionss for s in ss]
sessions.sort(key=lambda a: a['start'])
......@@ -110,20 +110,24 @@ def transform_session(session: Dict, day: int) -> List[Dict]:
Returns:
an uncluttered, organized version of the input dict containing only relevant data
"""
def build_session(title, url, providers, start):
def build_session(title, url, location, start, end):
result = {}
result['title'] = title
result['url'] = url
result['providers'] = providers
result['location'] = location
result['start'] = start
result['end'] = end
return result
def parse_date(start: Dict) -> datetime:
return datetime.fromtimestamp(int(start['timestamp']))
def process_provider(provider: Dict) -> str:
return sub('Assembly:', '', sub('Static:', '', provider['fulltext']))
return sub('Assembly:', '', sub('Room:', '', provider['fulltext']))
title = sub('Session:', '', session['fulltext'])
url = session['fullurl']
providers = ', '.join(map(process_provider, session['printouts']['organized by']))
start_dates = list(map(parse_date, session['printouts']['Start']))
location = session['printouts']['location']
location = process_provider(location[0]) if location else ''
start_dates = list(map(parse_date, session['printouts']['starts']))
starts = [s.strftime('%H:%M') for s in filter(lambda d: d.day == day, start_dates)]
return [build_session(title, url, providers, s) for s in starts]
end_dates = list(map(parse_date, session['printouts']['ends']))
ends = [s.strftime('%H:%M') for s in filter(lambda d: d.day == day, end_dates)]
return [build_session(title, url, location, s, e) for s, e in zip(starts, ends)]
......@@ -35,19 +35,19 @@
\textbf{Wann?} & \textbf{Was?} & \textbf{Wo?} & \textbf{URL}
\\ \hline \hline
%- for session in sessions
\VAR{session.start | e} & \VAR{session.title | e} & \VAR{session.providers | e}
\VAR{session.start | e} & \VAR{session.title | e} & \VAR{session.location | e}
& \qrcode{\VAR{session.url | e}}
\\ \hline
%- endfor
\end{longtable}
%- else
\begin{longtable}{|l|p{0.55\linewidth}|p{0.3\linewidth}|}
\begin{longtable}{|l|l|p{0.45\linewidth}|p{0.3\linewidth}|}
\hline
\textbf{Wann?} & \textbf{Was?} & \textbf{Wo?}
\textbf{Von} & \textbf{Bis} & \textbf{Was} & \textbf{Wo}
\\ \hline \hline
%- for session in sessions
\VAR{session.start | e} & \VAR{session.title | e} & \VAR{session.providers | e}
\VAR{session.start | e} & \VAR{session.end | e} & \VAR{session.title | e} & \VAR{session.location | e}
\\ \hline
%- endfor
\end{longtable}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment