From 4416ece0a9a7a2e121bdb9fa3ff76b20fa653c60 Mon Sep 17 00:00:00 2001 From: Trygve Date: Thu, 3 Mar 2022 15:39:59 +0100 Subject: [PATCH] =?UTF-8?q?Litt=20jobb=20p=C3=A5=20card=5Fpunch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev.py | 7 ++++--- otime.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dev.py b/dev.py index d64fca0..80fc69a 100644 --- a/dev.py +++ b/dev.py @@ -21,7 +21,8 @@ if __name__ == "__main__": event = otime.event(0, 'supercup') event.import_ttime_cnf('sc_2021_ttime/ttime.cnf.txt') event.import_ttime_db('sc_2021_ttime/db_eventor.csv') - #event.import_mtr_file('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.import_mtr_file('sc_2021_ttime/mtr.csv') + #card_punches = otime.card_punch.list_from_mtr_f('sc_2021_ttime/mtr.csv') + event.append_punch_list(event.card_punches) + event.match_runners_cards() event.get_xml_res().write('Resultater.xml') diff --git a/otime.py b/otime.py index b03a8ae..1acdf0b 100644 --- a/otime.py +++ b/otime.py @@ -30,9 +30,13 @@ class event: def import_ttime_db(self, ttime_file): self.add_runners(*ttime_db_to_class(ttime_file, self.o_classes)) - 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 def append_punch_list(self, punches): @@ -41,6 +45,8 @@ class event: if n.card == i.card: n.controls = list(i.punches.keys()) n.splits = list(i.punches.values()) + n.s_time = i.s_time + n.f_time = i.f_time def get_xml_res(self): root = ET.Element('ResultList') @@ -64,12 +70,9 @@ class event: runners_same_c = get_runners_in_class(self.runners, i) runners_ranked = rank_runners(runners_same_c, i) # 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] - print(len(runners_same_c), len(runners_ranked)) runners_ranked.extend(runners_sorted) - print(len(runners_same_c), len(runners_ranked)) for n in runners_ranked: person_result = ET.SubElement(class_result, 'PersonResult') # @@ -206,8 +209,7 @@ class card_punch: if controls[-1] == 250: s_time = f_time - datetime.timedelta(seconds = splits[-2]) 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)) return cards class course: