import event import athletes import clubs import start import finish from util import util import datetime event = event.load() clubs = clubs.load() start = start.load() flist = finish.load() aths = tuple(filter(lambda x: hasattr(x, "id"), athletes.build(clubs))) results = dict() results["name"] = event.name results["date"] = event.date results["mass"] = event.mass results["evals"] = list() for race in event.races: evaluations = list() if hasattr(race, "eval"): for evaluation in race.eval: e = dict() e["age_min"] = evaluation["age_min"] e["age_max"] = evaluation["age_max"] if e["age_min"] == e["age_max"]: e["desc"] = str(event.eff_year - e["age_max"]) else:
#!/usr/bin/env python3 import event import clubs import athletes import collections import hashlib event = event.load() clubs = clubs.load() aths = athletes.build(clubs, False) athsWithId = tuple(filter(lambda x: hasattr(x, "id"), aths)) # expect no id or id == 0 idCounter = collections.Counter(map(lambda x: x.id, athsWithId)) for i in idCounter: if i != 0 and idCounter[i] > 0: raise Exception("Athletes file athlete id " + str(i) + " defined " + str(idCounter[i]) + " times. Only zeros are expected!") number_red = 0 number_black = 100 for race in event.races: raceAths = list() for athlete in athsWithId: if (athlete.sex == race.sex and event.eff_year - athlete.born >= race.age_min and event.eff_year - athlete.born <= race.age_max): raceAths.append((athlete, hashlib.md5("{0}{1}{2}".format(athlete.name, athlete.surname, event.date).encode()).hexdigest())) raceAths.sort(key=lambda t: t[1])
#!/usr/bin/env python3 import clubs import athletes import argparse import locale import random try: locale.setlocale(locale.LC_COLLATE, "cs_CZ.utf8") except locale.Error: pass clubs = clubs.load() aths = athletes.build(clubs) aths = sorted(aths, key=lambda athlete : locale.strxfrm(athlete.surname)) aths = sorted(aths, key=lambda athlete : athlete.sex) aths = sorted(aths, key=lambda athlete : athlete.born, reverse=True) parser = argparse.ArgumentParser() parser.add_argument("--shuffle", help="shuffle names to anonymize and store as file SHUFFLE") args = parser.parse_args() if args.shuffle: for athlete in aths: athlete.name = ''.join(random.sample(athlete.name, len(athlete.name))).lower().title() athlete.surname = ''.join(random.sample(athlete.surname, len(athlete.surname))).lower().title() athletes.dump(aths, args.shuffle) else: athletes.dump(aths, "athletes-sorted.yaml")
import clubs import athletes from athletes.athlete import Athlete import collections import argparse import csv parser = argparse.ArgumentParser() parser.add_argument("file", help="csv file to register") args = parser.parse_args() event = event.load() clubs = clubs.load() aths = list(athletes.build(clubs, False)) with open(args.file, newline='') as f: reader = csv.reader(f) for row in reader: year = int(row[3]) present = False for a in aths: if row[1] == a.name and row[0] == a.surname and year == a.born: present = True if len(row) > 4: if row[4] in clubs: a.club = clubs[row[4]] else: raise Exception("Club " + row[4] + " of athlete " + row[0] + " not defined in clubs") a.id = 0