Begynte å fikse koden som lager strekktider

This commit is contained in:
Trygve 2022-05-30 22:14:25 +02:00
parent aee318bd0e
commit 437a71ff59

View File

@ -136,6 +136,8 @@ class Event:
# </Organisation> # </Organisation>
# <Result> # <Result>
result = ET.SubElement(person_result, 'Result') 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: 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, 'StartTime', n.card_r.s_time.isoformat())
xml_child(result, 'FinishTime', n.card_r.f_time.isoformat()) xml_child(result, 'FinishTime', n.card_r.f_time.isoformat())
@ -160,15 +162,11 @@ class Event:
controls = copy(n.card_r.controls) controls = copy(n.card_r.controls)
splits = copy(n.card_r.splits) 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') st = ET.SubElement(result, 'SplitTime')
xml_child(st, 'ControlCode', code) xml_child(st, 'ControlCode', code)
for control, split in zip(controls, splits): if split != None:
if code == control:
xml_child(st, 'Time', split) xml_child(st, 'Time', split)
controls.remove(control)
splits.remove(split)
break
else: else:
xml_child(result, 'Status', n.status()) xml_child(result, 'Status', n.status())
else: else:
@ -372,17 +370,36 @@ class Runner:
else: else:
return self.o_class.course.variations[self.fork] 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 # Used for making result files and tables
def res_splits(self): def res_splits(self):
if self.status() == 'OK':
splits_cpy = self.card_r.splits.copy() splits_cpy = self.card_r.splits.copy()
for control in self.card_r.controls: for control in self.card_r.controls:
if control not in self.res_codes(): if control not in self.res_codes():
index = self.card_r.controls.index(control) index = self.card_r.controls.index(control)
split = self.card_r.splits[index] split = self.card_r.splits[index]
splits_cpy.remove(split) splits_cpy.remove(split)
return splits_cpy # list return splits_cpy
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): def asdict(self):
return { return {
@ -390,7 +407,7 @@ class Runner:
'first': self.first, 'first': self.first,
'last': self.last, 'last': self.last,
'club_id': self.club_id, 'club_id': self.club_id,
'club': self.club_id, 'club': self.club,
'country': self.country, 'country': self.country,
'card': self.card, 'card': self.card,
'o_class_str': self.o_class_str, 'o_class_str': self.o_class_str,