# Path: dividebatur/aecdata/utils.py
# def ticket_sort_key(ticket):
#     "sort key for an ATL ticket, eg. A..Z, AA..ZZ"
#     return (len(ticket), ticket)
# 
# def named_tuple_iter(name, reader, header, **kwargs):
#     field_names = [t for t in [t.strip().replace('-', '_')
#                                for t in header] if t]
#     typ = namedtuple(name, field_names)
#     mappings = []
#     for field_name in kwargs:
#         idx = field_names.index(field_name)
#         mappings.append((idx, kwargs[field_name]))
#     for row in reader:
#         for idx, map_fn in mappings:
#             row[idx] = map_fn(row[idx])
#         yield typ(*row)


import csv
import collections
from .utils import ticket_sort_key, named_tuple_iter



Candidate = collections.namedtuple('Candidate', [
    'candidate_id',
    'surname',
    'given_name',
    'candidate_order',  # Position within the entire ballot, 0 based.
    'group_id',         # Group ID

# Path: dividebatur/aecdata/utils.py
# def ticket_sort_key(ticket):
#     "sort key for an ATL ticket, eg. A..Z, AA..ZZ"
#     return (len(ticket), ticket)
# 
# def named_tuple_iter(name, reader, header, **kwargs):
#     field_names = [t for t in [t.strip().replace('-', '_')
#                                for t in header] if t]
#     typ = namedtuple(name, field_names)
#     mappings = []
#     for field_name in kwargs:
#         idx = field_names.index(field_name)
#         mappings.append((idx, kwargs[field_name]))
#     for row in reader:
#         for idx, map_fn in mappings:
#             row[idx] = map_fn(row[idx])
#         yield typ(*row)


# Path: dividebatur/aecdata/candidatelist.py
import csv
import collections
from .utils import ticket_sort_key, named_tuple_iter




Candidate = collections.namedtuple('Candidate', [
    'candidate_id',
    'surname',
    'given_name',
    'candidate_order',  # Position within the entire ballot, 0 based.
    'group_id',         # Group ID

    'ballot_position',  # Position within group, 1 based.