Legger inn riktig klasseobjekt i løperobjektet
This commit is contained in:
parent
b063a61c7e
commit
944b9d0fd6
10
cli.py
10
cli.py
@ -8,9 +8,10 @@ def print_runners(Runners):
|
|||||||
table.add_column("club", style="magenta")
|
table.add_column("club", style="magenta")
|
||||||
table.add_column("card", style="red")
|
table.add_column("card", style="red")
|
||||||
table.add_column("class", justify="right", style="green")
|
table.add_column("class", justify="right", style="green")
|
||||||
|
table.add_column("controls", justify="right", style="blue")
|
||||||
|
|
||||||
for i in Runners:
|
for i in Runners:
|
||||||
table.add_row(i.fullname(), i.club ,str(i.card), i.o_class)
|
table.add_row(i.fullname(), i.club ,str(i.card), i.o_class.name, str(i.controls))
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
console.print(table)
|
console.print(table)
|
||||||
@ -29,7 +30,8 @@ def print_o_classes(class_list):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
courses = otime.courses_from_ttime_conf('sc_2021_ttime/ttime.cnf.txt')
|
courses = otime.courses_from_ttime_conf('sc_2021_ttime/ttime.cnf.txt')
|
||||||
o_classes = otime.classes_from_ttime_conf('sc_2021_ttime/ttime.cnf.txt', courses)
|
o_classes = otime.classes_from_ttime_conf('sc_2021_ttime/ttime.cnf.txt', courses)
|
||||||
Runners = otime.xml_to_class()
|
runner_list = otime.xml_to_class('entries_KOK_Sommercup,_løp_2.xml', o_classes)
|
||||||
|
otime.ttime_mtr_to_class('sc_2021_ttime/mtr.csv', runner_list)
|
||||||
print_runners(Runners)
|
print_runners(runner_list)
|
||||||
print_o_classes(o_classes)
|
print_o_classes(o_classes)
|
||||||
|
otime.check_codes(runner_list[21], o_classes)
|
||||||
|
41
otime.py
41
otime.py
@ -41,10 +41,8 @@ def courses_from_ttime_conf(ttime_file = 'sc_2021_ttime/ttime.cnf.txt'):
|
|||||||
for n in code_list:
|
for n in code_list:
|
||||||
n = n.split(',')
|
n = n.split(',')
|
||||||
loops += 1
|
loops += 1
|
||||||
|
n = list(map(int, n))
|
||||||
courses.append(course('course_'+str(loops), n))
|
courses.append(course('course_'+str(loops), n))
|
||||||
print(n)
|
|
||||||
print(courses)
|
|
||||||
print(courses[1].name)
|
|
||||||
return courses
|
return courses
|
||||||
def classes_from_ttime_conf(ttime_file, courses):
|
def classes_from_ttime_conf(ttime_file, courses):
|
||||||
o_classes = []
|
o_classes = []
|
||||||
@ -59,11 +57,10 @@ def classes_from_ttime_conf(ttime_file, courses):
|
|||||||
o_classes.append(o_class(i,courses[loops]))
|
o_classes.append(o_class(i,courses[loops]))
|
||||||
loops += 1
|
loops += 1
|
||||||
|
|
||||||
print(o_classes[1].course.codes)
|
|
||||||
|
|
||||||
return o_classes
|
return o_classes
|
||||||
|
|
||||||
def xml_to_class(xml_file = 'entries_KOK_Sommercup,_løp_2.xml'):
|
def xml_to_class(xml_file, o_class_list=[]):
|
||||||
tree = ET.parse(xml_file)
|
tree = ET.parse(xml_file)
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
runnerarray = []
|
runnerarray = []
|
||||||
@ -81,10 +78,17 @@ def xml_to_class(xml_file = 'entries_KOK_Sommercup,_løp_2.xml'):
|
|||||||
except:
|
except:
|
||||||
card = 0
|
card = 0
|
||||||
try:
|
try:
|
||||||
o_class = person_root[4][1].text
|
xml_class_str = person_root[4][1].text
|
||||||
except:
|
except:
|
||||||
o_class = "None"
|
# VELDIG MIDLERTIDIG
|
||||||
runnerarray.append(runner(first, last, club, country, card, o_class, [], []))
|
runner_o_class = o_class_list[0]
|
||||||
|
else:
|
||||||
|
for i in o_class_list:
|
||||||
|
if i.name == xml_class_str:
|
||||||
|
runner_o_class = i
|
||||||
|
break
|
||||||
|
# Gjør sånn at den lager nye o klasser om den ikke finnes fra før
|
||||||
|
runnerarray.append(runner(first, last, club, country, card, runner_o_class, [], []))
|
||||||
return runnerarray
|
return runnerarray
|
||||||
def ttime_mtr_to_class(csv_file, runnerarray):
|
def ttime_mtr_to_class(csv_file, runnerarray):
|
||||||
csvreader = csv.reader(open(csv_file))
|
csvreader = csv.reader(open(csv_file))
|
||||||
@ -106,25 +110,14 @@ def ttime_mtr_to_class(csv_file, runnerarray):
|
|||||||
for item in row[12::2]:
|
for item in row[12::2]:
|
||||||
if item != '000' and item != '0000' and item != '00000':
|
if item != '000' and item != '0000' and item != '00000':
|
||||||
splits.append(int(item))
|
splits.append(int(item))
|
||||||
print(row[6])
|
|
||||||
# looper gjonnom løperobjektene og legger til poster og strekktider
|
# looper gjonnom løperobjektene og legger til poster og strekktider
|
||||||
for runner in runnerarray:
|
for runner in runnerarray:
|
||||||
if runner.card == int(row[6]):
|
if runner.card == int(row[6]):
|
||||||
runner.controls = controls
|
runner.controls = controls
|
||||||
runner.splits = splits
|
runner.splits = splits
|
||||||
|
def check_codes(runner, course_list):
|
||||||
|
print(runner.fullname())
|
||||||
|
print(runner.o_class.name)
|
||||||
|
print(runner.controls)
|
||||||
|
print(runner.o_class.course.codes)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
import_ttime_conf()
|
|
||||||
Runners = xml_to_class()
|
|
||||||
#print(Runners[4].last)
|
|
||||||
#print_table(Runners)
|
|
||||||
#ttime_mtr_to_class('sc_2021_ttime/mtr.csv', Runners)
|
|
||||||
"""
|
|
||||||
for i in Runners:
|
|
||||||
print(i.first + ' ' + i.last)
|
|
||||||
print(i.controls)
|
|
||||||
#print(i.splits)
|
|
||||||
try:
|
|
||||||
print(str(datetime.timedelta(seconds = i.splits[-1])))
|
|
||||||
except: print('ikke deltatt')
|
|
||||||
"""
|
|
||||||
|
Loading…
Reference in New Issue
Block a user