def __init__(self, line): tokens = line.split("|") num_tokens = len(tokens) # Figure out what version data we have version = 0 if tokens[0].startswith("V"): version = int(tokens[0][1:]) if version == 1: self.asa_number = int(tokens[1]) self.event = Event(int(tokens[2])) self.date = helpers.ParseDate_dmY(tokens[3]) self.meet = tokens[4] self.asa_swim_id = int(tokens[5]) # Splits are in tokens[6] self.splits = tokens[6] self.is_licensed = True if tokens[7] == 'n': self.is_licensed = False self.race_time = float(tokens[8]) self.short_course_race_time = self.race_time if self.event.is_long_course(): self.short_course_race_time = self.event.convert_time( self.race_time) #print( str( self.short_course_race_time ) ) else: raise RuntimeError("Unhandled swim version")
def from_club_rankings(cls, is_male, tokens) -> 'Swimmer': asa_number = int( tokens[3] ) names = tokens[0].split(' ') last_name = names[1].strip() first_name = names[0].strip() known_as = '' date_of_birth = helpers.ParseDate_dmY( tokens[1] ) return cls(is_male, first_name, last_name, asa_number, date_of_birth, known_as)
def from_old_format(cls, str) -> 'Swimmer': tokens = str.split( '|' ) num_tokens = len( tokens ) is_male = False if tokens[4] == 'M': is_male = True asa_number = int(tokens[0]) last_name = tokens[1] first_name = tokens[2] known_as = tokens[3] date_of_birth = helpers.ParseDate_dmY( tokens[5] ) return cls(is_male, first_name, last_name, asa_number, date_of_birth, known_as)
def __init__(self, asa_number, event, tokens): token_offset = 0 if len(tokens) == 6: token_offset = 1 self.asa_number = asa_number self.event = event self.date = helpers.ParseDate_dmY(tokens[token_offset]) self.meet = tokens[token_offset + 1].strip() self.asa_swim_id = 0 self.splits = None self.level = int(tokens[token_offset + 3]) self.race_time = float(RaceTime(tokens[token_offset + 4])) self.short_course_race_time = self.race_time if self.event.is_long_course(): self.short_course_race_time = self.event.convert_time( self.race_time)
def __init__(self, request): distance_str = request.get('distance') gender_str = request.get('gender') min_age_str = request.get('min_age') max_age_str = request.get('max_age') date_str = request.get('date') # Validate args if (distance_str is None) or (gender_str is None) or ( min_age_str is None) or (max_age_str is None) or (date_str is None): self.error = True return self.is_male = (gender_str[0:1] == "M") self.distance = int(distance_str) self.min_age = int(min_age_str) self.max_age = int(max_age_str) self.date = helpers.ParseDate_dmY(date_str)
maximum_age = 23 # Any swimmer older will be excluded # Swimmers that are in our database that no longer swim for Winsford excluded_swimmers = { "Abbie Christopherson", "Alice Deeming", "Alisha Hawkins", "Amber Rose", "Anna Crossland", "Ashley Hogg", "Benjamin Townsend", "Brandon Sharkey", "Callum Chapple", "Charlotte Howman", "Charlotte Pagett", "Daniel Hulme", "Ellie Cushen", "Emily Riddick", "Georgia Farr", "Grace Farr", "Hannah McEnaney", "Harrison Aspinall", "Jamie Young", "Jordan Gaskell", "Kate Kenworthy", "Kate Young", "Katie Wilson", "Keaton Haydon", "Kyle Hawkins", "Liadan Wilkes", "Lily Harwood", "Lydia Rose", "Poppy Maskill", "Rebecca Broadhurst", "Rose Maskill", "Samuel James", "Thomas Bloor", "William James" } age_on_date = helpers.ParseDate_dmY(age_on_date_str) earliest_pb_date = helpers.ParseDate_dmY(earliest_pb_date_str) num_events = len(short_course_events) def process_swimmer(swimmer, swims): age = helpers.CalcAge(swimmer.date_of_birth, age_on_date) full_name = swimmer.full_name() if full_name in excluded_swimmers: return if age > maximum_age: return full_name = swimmer.alternate_name()
from swim import Swim from swimmer import Swimmer from race_time import RaceTime from event import short_course_events import read_club_rankings folder = 'output/' race_times_file = open(folder + 'RaceTimes.txt', 'w') club_champs_start_date_str = '8/9/2019' club_champs_end_date_str = '21/9/2019' maximum_age = 21 # Any swimmer older will be excluded club_champs_meet_name = 'Winsford Club Championships 2019' club_champs_start_date = helpers.ParseDate_dmY(club_champs_start_date_str) club_champs_end_date = helpers.ParseDate_dmY(club_champs_end_date_str) num_events = len(short_course_events) class ConsiderationTime(): def __init__(self, event, time, reason): self.event = event self.time = time self.reason = reason class SwimmerTimes(): def __init__(self, swimmer, full_name): self.swimmer = swimmer self.full_name = full_name