From 77ea1385f92a21803865e5ff6fdc335c699e7406 Mon Sep 17 00:00:00 2001 From: Trygve Date: Wed, 9 Mar 2022 18:06:59 +0100 Subject: [PATCH] =?UTF-8?q?Begynte=20=C3=A5=20porte=20cli.py=20til=20event?= =?UTF-8?q?=20modellen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli.py | 26 ++++++++++++++------------ otime.py | 4 ++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cli.py b/cli.py index 8a92a2c..3c30c23 100755 --- a/cli.py +++ b/cli.py @@ -14,10 +14,10 @@ def print_runners(Runners): table.add_column("club", style="magenta") table.add_column("card", style="red") table.add_column("class", justify="right", style="green") - table.add_column("controls", justify="right", style="blue") + table.add_column("Status", justify="right", style="blue") for i in Runners: - table.add_row(i.fullname(), i.club ,str(i.card), i.o_class.name, str(i.controls)) + table.add_row(i.fullname(), i.club ,str(i.card), i.o_class.name, i.status()) console = Console() console.print(table) @@ -131,17 +131,19 @@ def main(): args = parser.parse_args() if args.command == 'show_runners': - courses = otime.courses_from_ttime_conf(args.ttcnf) - o_classes = otime.classes_from_ttime_conf(args.ttcnf, courses) - runner_list = otime.ttime_db_to_class(args.ttdb, o_classes) - otime.ttime_mtr_to_class(args.mtr, runner_list) - print_runners(runner_list) + event = otime.event(0, 'NoName') + event.import_ttime_cnf(args.ttcnf) + event.import_ttime_db(args.ttdb) + event.import_mtr_file(args.mtr) + event.match_runners_cards() + print_runners(event.runners) elif args.command == 'show_runner': - courses = otime.courses_from_ttime_conf(args.ttcnf) - o_classes = otime.classes_from_ttime_conf(args.ttcnf, courses) - runner_list = otime.ttime_db_to_class(args.ttdb, o_classes) - otime.ttime_mtr_to_class(args.mtr, runner_list) - for n in runner_list: + event = otime.event(0, 'NoName') + event.import_ttime_cnf(args.ttcnf) + event.import_ttime_db(args.ttdb) + event.import_mtr_file(args.mtr) + event.match_runners_cards() + for n in event.runners: if args.runner == n.fullname(): inspect(n) break diff --git a/otime.py b/otime.py index 0b9e13e..dcbae58 100644 --- a/otime.py +++ b/otime.py @@ -177,6 +177,8 @@ class card_punch: cards = [] # hver rad er brikkenummer med tilhørende info for row in csvreader: + if len(row) == 0: + continue rows.append(row) controls = [] splits = [] @@ -281,6 +283,8 @@ def ttime_db_to_class(ttime_file, o_class_list=[]): csvreader = csv.reader(open(ttime_file, 'r', encoding='latin_1'), delimiter=';',) runnerarray = [] for row in csvreader: + if len(row) == 0: + continue eventorid = row[0] country = '' name = row[2].split(',')