Litt jobb på card_punch

This commit is contained in:
Trygve 2022-03-03 15:39:59 +01:00
parent d5b04a1a66
commit 4416ece0a9
2 changed files with 13 additions and 10 deletions

7
dev.py
View File

@ -21,7 +21,8 @@ if __name__ == "__main__":
event = otime.event(0, 'supercup') event = otime.event(0, 'supercup')
event.import_ttime_cnf('sc_2021_ttime/ttime.cnf.txt') event.import_ttime_cnf('sc_2021_ttime/ttime.cnf.txt')
event.import_ttime_db('sc_2021_ttime/db_eventor.csv') event.import_ttime_db('sc_2021_ttime/db_eventor.csv')
#event.import_mtr_file('sc_2021_ttime/mtr.csv') event.import_mtr_file('sc_2021_ttime/mtr.csv')
card_punches = otime.card_punch.list_from_mtr_f('sc_2021_ttime/mtr.csv') #card_punches = otime.card_punch.list_from_mtr_f('sc_2021_ttime/mtr.csv')
event.append_punch_list(card_punches) event.append_punch_list(event.card_punches)
event.match_runners_cards()
event.get_xml_res().write('Resultater.xml') event.get_xml_res().write('Resultater.xml')

View File

@ -30,9 +30,13 @@ class event:
def import_ttime_db(self, ttime_file): def import_ttime_db(self, ttime_file):
self.add_runners(*ttime_db_to_class(ttime_file, self.o_classes)) self.add_runners(*ttime_db_to_class(ttime_file, self.o_classes))
def import_mtr_file(self, mtr_file): def import_mtr_file(self, mtr_file):
ttime_mtr_to_class(mtr_file, self.runners) self.card_punches = card_punch.list_from_mtr_f(mtr_file)
def match_runners_cards(self):
for n in self.runners:
for i in self.card_punches:
if n.card == i.card:
n.card_r = i
# MIDLERTIDIG # MIDLERTIDIG
def append_punch_list(self, punches): def append_punch_list(self, punches):
@ -41,6 +45,8 @@ class event:
if n.card == i.card: if n.card == i.card:
n.controls = list(i.punches.keys()) n.controls = list(i.punches.keys())
n.splits = list(i.punches.values()) n.splits = list(i.punches.values())
n.s_time = i.s_time
n.f_time = i.f_time
def get_xml_res(self): def get_xml_res(self):
root = ET.Element('ResultList') root = ET.Element('ResultList')
@ -64,12 +70,9 @@ class event:
runners_same_c = get_runners_in_class(self.runners, i) runners_same_c = get_runners_in_class(self.runners, i)
runners_ranked = rank_runners(runners_same_c, i) runners_ranked = rank_runners(runners_same_c, i)
# Put the OK runners first and Active last # Put the OK runners first and Active last
print(len(runners_same_c), len(runners_ranked))
runners_sorted = [i for i in runners_same_c if i not in runners_ranked] runners_sorted = [i for i in runners_same_c if i not in runners_ranked]
print(len(runners_same_c), len(runners_ranked))
runners_ranked.extend(runners_sorted) runners_ranked.extend(runners_sorted)
print(len(runners_same_c), len(runners_ranked))
for n in runners_ranked: for n in runners_ranked:
person_result = ET.SubElement(class_result, 'PersonResult') person_result = ET.SubElement(class_result, 'PersonResult')
#<Person> #<Person>
@ -206,8 +209,7 @@ class card_punch:
if controls[-1] == 250: if controls[-1] == 250:
s_time = f_time - datetime.timedelta(seconds = splits[-2]) s_time = f_time - datetime.timedelta(seconds = splits[-2])
else: else:
pass s_time = f_time
#s_time = f_time
cards.append(card_punch(int(row[6]), dict(zip(controls, splits)), s_time, f_time)) cards.append(card_punch(int(row[6]), dict(zip(controls, splits)), s_time, f_time))
return cards return cards
class course: class course: