Compare commits
2 Commits
88ba0c9da9
...
aee318bd0e
Author | SHA1 | Date | |
---|---|---|---|
aee318bd0e | |||
caca1fac99 |
45
otime.py
45
otime.py
@ -1,3 +1,4 @@
|
|||||||
|
from copy import copy
|
||||||
import datetime
|
import datetime
|
||||||
import csv
|
import csv
|
||||||
import re
|
import re
|
||||||
@ -112,6 +113,8 @@ class Event:
|
|||||||
runners_ranked.extend(runners_sorted)
|
runners_ranked.extend(runners_sorted)
|
||||||
|
|
||||||
for n in runners_ranked:
|
for n in runners_ranked:
|
||||||
|
if n.status() == 'Active':
|
||||||
|
continue
|
||||||
person_result = ET.SubElement(class_result, 'PersonResult')
|
person_result = ET.SubElement(class_result, 'PersonResult')
|
||||||
# <Person>
|
# <Person>
|
||||||
person = ET.SubElement(person_result, 'Person')
|
person = ET.SubElement(person_result, 'Person')
|
||||||
@ -149,17 +152,23 @@ class Event:
|
|||||||
st = ET.SubElement(result, 'SplitTime')
|
st = ET.SubElement(result, 'SplitTime')
|
||||||
xml_child(st, 'ControlCode', code)
|
xml_child(st, 'ControlCode', code)
|
||||||
xml_child(st, 'Time', split)
|
xml_child(st, 'Time', split)
|
||||||
if code == n.o_class.course.codes[-1]:
|
if code == n.res_codes()[-1]:
|
||||||
break
|
break
|
||||||
# </SplitTime>
|
# </SplitTime>
|
||||||
elif n.status() == 'Disqualified':
|
elif n.status() == 'Disqualified':
|
||||||
xml_child(result, 'Status', n.status())
|
xml_child(result, 'Status', n.status())
|
||||||
for code in n.o_class.course.codes:
|
|
||||||
|
controls = copy(n.card_r.controls)
|
||||||
|
splits = copy(n.card_r.splits)
|
||||||
|
for code in n.res_codes():
|
||||||
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(n.card_r.controls, n.card_r.splits):
|
for control, split in zip(controls, splits):
|
||||||
if code == control:
|
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:
|
||||||
@ -206,7 +215,7 @@ class Event:
|
|||||||
|
|
||||||
courses = []
|
courses = []
|
||||||
for c in data['courses']:
|
for c in data['courses']:
|
||||||
courses.append(Course(c['name'], c['codes']))
|
courses.append(Course(c['name'], c['codes'], forked=c['forked'], variations=c['variations']))
|
||||||
|
|
||||||
o_classes = []
|
o_classes = []
|
||||||
for c in data['o_classes']:
|
for c in data['o_classes']:
|
||||||
@ -335,11 +344,10 @@ class Runner:
|
|||||||
return '{} {}'.format(self.first, self.last)
|
return '{} {}'.format(self.first, self.last)
|
||||||
|
|
||||||
def check_codes(self):
|
def check_codes(self):
|
||||||
# Returns False if not ok and touple if ok
|
return contains(self.res_codes(), self.card_r.controls)
|
||||||
return contains(self.o_class.course.codes, list(self.card_r.controls))
|
|
||||||
|
|
||||||
def totaltime(self):
|
def totaltime(self):
|
||||||
f_control = self.o_class.course.codes[-1]
|
f_control = self.res_codes()[-1]
|
||||||
try:
|
try:
|
||||||
index = self.card_r.controls.index(f_control)
|
index = self.card_r.controls.index(f_control)
|
||||||
return self.card_r.splits[index]
|
return self.card_r.splits[index]
|
||||||
@ -358,15 +366,24 @@ class Runner:
|
|||||||
c_ranked = rank_runners(allrunners, self.o_class)
|
c_ranked = rank_runners(allrunners, self.o_class)
|
||||||
return c_ranked.index(self) + 1
|
return c_ranked.index(self) + 1
|
||||||
|
|
||||||
|
def res_codes(self):
|
||||||
|
if self.o_class.course.forked == False:
|
||||||
|
return self.o_class.course.codes
|
||||||
|
else:
|
||||||
|
return self.o_class.course.variations[self.fork]
|
||||||
|
|
||||||
|
# Used for making result files and tables
|
||||||
def res_splits(self):
|
def res_splits(self):
|
||||||
|
|
||||||
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.o_class.course.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 # list
|
||||||
|
|
||||||
|
|
||||||
def asdict(self):
|
def asdict(self):
|
||||||
return {
|
return {
|
||||||
'id': self.id,
|
'id': self.id,
|
||||||
@ -494,14 +511,14 @@ class Course:
|
|||||||
self.codes = codes
|
self.codes = codes
|
||||||
|
|
||||||
try:
|
try:
|
||||||
forked = kwargs['forked']
|
self.forked = kwargs['forked']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
forked = False
|
self.forked = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
variations = kwargs['variations']
|
self.variations = kwargs['variations']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
variations = None
|
self.variations = None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'name({self.name})'
|
return f'name({self.name})'
|
||||||
@ -509,7 +526,9 @@ class Course:
|
|||||||
def asdict(self):
|
def asdict(self):
|
||||||
return {
|
return {
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
'codes': self.codes
|
'codes': self.codes,
|
||||||
|
'forked': self.forked,
|
||||||
|
'variations': self.variations
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stored in Event.o_classes
|
# Stored in Event.o_classes
|
||||||
|
11
wizard.py
11
wizard.py
@ -21,7 +21,7 @@ def main():
|
|||||||
case 1:
|
case 1:
|
||||||
import_menu()
|
import_menu()
|
||||||
case 2:
|
case 2:
|
||||||
print('export')
|
export_menu()
|
||||||
case 3:
|
case 3:
|
||||||
print('edit')
|
print('edit')
|
||||||
case 4:
|
case 4:
|
||||||
@ -131,7 +131,8 @@ def export_menu():
|
|||||||
global event
|
global event
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
print(''' 1. export otime file
|
print(''' 1. Export otime file
|
||||||
|
2. Export iof 3.0 xml file
|
||||||
2. Back''')
|
2. Back''')
|
||||||
try:
|
try:
|
||||||
opt = int(input('Choose an option (1-2): '))
|
opt = int(input('Choose an option (1-2): '))
|
||||||
@ -142,9 +143,13 @@ def export_menu():
|
|||||||
case 1:
|
case 1:
|
||||||
filename = input('File: ')
|
filename = input('File: ')
|
||||||
f = open(filename, 'w')
|
f = open(filename, 'w')
|
||||||
f.write(event.create_json_file)
|
f.write(event.create_json_file())
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
filename = input('File: ')
|
||||||
|
event.get_xml_res().write(filename)
|
||||||
|
|
||||||
|
case 3:
|
||||||
break
|
break
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
Loading…
Reference in New Issue
Block a user