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>
# <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:
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,