From 437a71ff5938075fb725c5b9f8a29f9a79a40ded Mon Sep 17 00:00:00 2001 From: Trygve Date: Mon, 30 May 2022 22:14:25 +0200 Subject: [PATCH] =?UTF-8?q?Begynte=20=C3=A5=20fikse=20koden=20som=20lager?= =?UTF-8?q?=20strekktider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otime.py | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/otime.py b/otime.py index f34fe99..6a4554c 100644 --- a/otime.py +++ b/otime.py @@ -136,6 +136,8 @@ class Event: # # result = ET.SubElement(person_result, 'Result') + + # TODO: Dette bør skrives om til å bruke Runner metoder så mye som mulig. if hasattr(n, 'card_r') and len(n.card_r.splits) > 2: xml_child(result, 'StartTime', n.card_r.s_time.isoformat()) xml_child(result, 'FinishTime', n.card_r.f_time.isoformat()) @@ -160,15 +162,11 @@ class Event: controls = copy(n.card_r.controls) splits = copy(n.card_r.splits) - for code in n.res_codes(): + for code, split in zip(n.res_codes(), n.res_splits()): st = ET.SubElement(result, 'SplitTime') xml_child(st, 'ControlCode', code) - for control, split in zip(controls, splits): - if code == control: - xml_child(st, 'Time', split) - controls.remove(control) - splits.remove(split) - break + if split != None: + xml_child(st, 'Time', split) else: xml_child(result, 'Status', n.status()) else: @@ -372,17 +370,36 @@ class Runner: else: return self.o_class.course.variations[self.fork] + # TODO: Mange bugs med løyper som har samme post flere ganger # Used for making result files and tables def res_splits(self): + if self.status() == 'OK': + splits_cpy = self.card_r.splits.copy() + for control in self.card_r.controls: + if control not in self.res_codes(): + index = self.card_r.controls.index(control) + split = self.card_r.splits[index] + splits_cpy.remove(split) + return splits_cpy - splits_cpy = self.card_r.splits.copy() - for control in self.card_r.controls: - if control not in self.res_codes(): - index = self.card_r.controls.index(control) - split = self.card_r.splits[index] - splits_cpy.remove(split) - return splits_cpy # list - + else: + splits_cpy = self.card_r.splits.copy() + for control in self.card_r.controls: + if control not in self.res_codes(): + index = self.card_r.controls.index(control) + split = self.card_r.splits[index] + splits_cpy.remove(split) + punches = self.card_r.controls.copy() + splits = [] + for code in self.res_codes(): + if punches[0] == code: + splits.append(splits_cpy[0]) + splits_cpy.pop(0) + punches.pop(0) + continue + else: + splits.append(None) + return splits def asdict(self): return { @@ -390,7 +407,7 @@ class Runner: 'first': self.first, 'last': self.last, 'club_id': self.club_id, - 'club': self.club_id, + 'club': self.club, 'country': self.country, 'card': self.card, 'o_class_str': self.o_class_str,