Skip to content

Commit

Permalink
Generate poster numbers
Browse files Browse the repository at this point in the history
- Each non-demo poster in a session gets a number based on its position in the session. These numbers are used to help locate the posters in the real world.
  • Loading branch information
desilinguist committed May 31, 2019
1 parent 75ef4ff commit 8f847e8
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions code/orderfile.py
Expand Up @@ -9,6 +9,7 @@
import re

from datetime import datetime
from itertools import count

_METADATA_REGEXP = re.compile(r'%([^\s]+)\s+([^%]+)')

Expand Down Expand Up @@ -54,6 +55,7 @@ def __init__(self, event):
super(Agenda, self).__init__()
self.event = event
self.days = []
self._poster_number_counter = count(1)

def save_states(self,
current_tuple,
Expand Down Expand Up @@ -111,6 +113,14 @@ def save_states(self,
# if there is an active item ...
if current_item:

# and it's a poster not a demo, generate a poster number
# and assign it as extended metadata; these numbers will
# allow attendees to locate them in the real world
if (current_item.type == 'poster' and not
current_item.id_.endswith('-demos')):
poster_number = next(self._poster_number_counter)
current_item.extended_metadata['poster_number'] = poster_number

# add it to the active session
if current_session:
current_session.add(current_item)
Expand All @@ -128,15 +138,25 @@ def save_states(self,
else:
current_day.add(current_session)

# also reset the poster number counter
self._poster_number_counter = count(1)

# save the currently active session group, if
# any, to the active day
if save_group and current_session_group:

current_day.add(current_session_group)

# also reset the poster number counter
self._poster_number_counter = count(1)

# save the active day to the agenda
if save_day:
self.days.append(current_day)

# also reset the poster number counter
self._poster_number_counter = count(1)

def fromfile(self, filepath):
"""
A method to create an `Agenda` object from
Expand Down Expand Up @@ -205,6 +225,7 @@ def fromfile(self, filepath):
# if we encounter a new session group ...
elif line.startswith('+ '):

# update the states
self.save_states((current_day,
current_session_group,
current_session,
Expand Down Expand Up @@ -232,6 +253,7 @@ def fromfile(self, filepath):
save_day=False,
save_group=False)

# nullify any previously active item
current_item = None

# make this new session the active one
Expand Down Expand Up @@ -464,8 +486,7 @@ class Session(object):
and a session chair (if any).
"""

# _plenary_regexp = re.compile(r'! ([0-9]{1,2}:[0-9]{2})--([0-9]{1,2}:[0-9]{2})\s+([^#]+)#?([^#]+)?$')
# _presentation_session_regexp = re.compile(r'=\s*(([0-9]{1,2}:[0-9]{2})--([0-9]{1,2}:[0-9]{2}))?\s*([^:#]+)?#?([^#]+)?$')
# define regular expressions to parse the session strings
_any_session_regexp = re.compile(r'^([!=])\s*(([0-9]{1,2}:[0-9]{2})--([0-9]{1,2}:[0-9]{2}))?\s*([^#]+)?#?([^#]+)?$')
_session_id_regexp = re.compile('Session ([0-9A-Za-z]+)\s*:')

Expand Down

0 comments on commit 8f847e8

Please sign in to comment.