From 24f8c30c8124e3def32d28a7c2a900795adfe2ae Mon Sep 17 00:00:00 2001 From: Trygve Date: Fri, 24 Nov 2023 00:41:38 +0100 Subject: [PATCH] Fiksa gaflinger --- otime/file_io.py | 2 +- otime/iof_xml.py | 2 +- otime/otime.py | 13 ++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/otime/file_io.py b/otime/file_io.py index b61ce24..9881576 100644 --- a/otime/file_io.py +++ b/otime/file_io.py @@ -38,7 +38,7 @@ def event_from_yaml_and_csv(config_path, mtr_path, csv_path): with open(csv_path, 'r') as f: data = [i.split(';') for i in f.readlines()] for i in data: i[2] = i[2].split(',') - runners = [otime.Runner(id=i[0], status_override=i[1], first=i[2][0], last=i[2][1].strip(), o_class=i[3], club=i[4], card_id=int(i[5]), fork=i[6], start_time=i[7]) for i in data] + runners = [otime.Runner(id=i[0], status_override=i[1], first=i[2][0], last=i[2][1].strip(), o_class=i[3], club=i[4], card_id=int(i[5]), fork=int(i[6]), start_time=i[7]) for i in data] event.card_dumps = card_dumps event.runners = runners return event \ No newline at end of file diff --git a/otime/iof_xml.py b/otime/iof_xml.py index 4145294..4c4231c 100644 --- a/otime/iof_xml.py +++ b/otime/iof_xml.py @@ -172,7 +172,7 @@ def courses_from_xml(xml_file): controls.remove('STA1') controls.remove('FIN1') controls = [int(l) for l in controls] - courseobjs.append(otime.Course(name, controls)) + courseobjs.append(otime.Course(name, [controls])) return courseobjs def event_from_xml_entries(xml_file): diff --git a/otime/otime.py b/otime/otime.py index d13b999..2f6e26a 100644 --- a/otime/otime.py +++ b/otime/otime.py @@ -161,12 +161,11 @@ class CardDump: # Stored in Event.courses class Course: - def __init__(self, name, codes, forked=False, variations=None): + def __init__(self, name, codes, forked=False): self.name = name + # Codes is a list of courses self.codes = codes self.forked = forked - # Variations is a list - self.variations = variations def __repr__(self): return f'name({self.name})' @@ -270,7 +269,7 @@ class Event: course = self.get_course(o_class.course) if not self.get_card_dump(runner.card_id): return 'Active' - if contains(course.codes, self.get_card_dump(runner.card_id).controls): + if contains(course.codes[runner.fork], self.get_card_dump(runner.card_id).controls): return 'OK' else: return 'MissingPunch' @@ -306,8 +305,8 @@ class Event: return None split_iter = zip(card_dump.controls, card_dump.splits).__iter__() - splits = [0] * len(course.codes) - for n, control in enumerate(course.codes): + splits = [0] * len(course.codes[runner.fork]) + for n, control in enumerate(course.codes[runner.fork]): if control not in card_dump.controls: continue while True: @@ -404,7 +403,7 @@ def courses_from_ttime_conf(ttime_file): n = n.split(',') loops += 1 n = list(map(int, n)) - courses.append(Course('course_'+str(loops), n)) + courses.append(Course('course_'+str(loops), [n])) return courses def classes_from_ttime_conf(ttime_file, courses):