Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def even(x):
def is_valid_seat(seat):
return all (key in seat for key in ("row", "seat", "x1", "x2", "y1", "y2"))

def is_hall_position(seat):
return all (key in seat for key in ("hall", "type", "x", "y"))

def get_hall_from_table_name(table):
return re.search('([A-Za-z]+)[0-9]+', table).group(1)
Expand All @@ -26,11 +28,11 @@ def normalize_table_name(table):
def add_coordinates(seatmap, cursor):
halls = {}
tables = {}
# Currently we don't use the "hall" property of the seatmap but calculate
# our own grouping based on the initial non-numeric characters in the table
# name. That way we work around the human naming of halls.
for seat in seatmap:
if not is_valid_seat(seat):
if is_hall_position(seat):
hall = seat['hall']
cursor.execute("INSERT INTO hall_positions VALUES (?,?,?)", (seat['hall'], seat['x'], seat['y']))
continue
table = normalize_table_name(seat['row'])
logging.debug("Normalized table name %s to %s", seat['row'], table)
Expand Down
6 changes: 6 additions & 0 deletions lib/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def create(conn):
y INTEGER,
table_name TEXT)''')

# Hall positions
c.execute('''CREATE TABLE hall_positions(
name TEXT,
x INTEGER,
y INTEGER)''')

# Meta data
c.execute('''CREATE TABLE meta_data(name TEXT, value TEXT)''')

Expand Down