Begynte å porte cli.py til event modellen

This commit is contained in:
Trygve 2022-03-09 18:06:59 +01:00
parent 8888a52ff2
commit 77ea1385f9
2 changed files with 18 additions and 12 deletions

26
cli.py
View File

@ -14,10 +14,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") table.add_column("Status", 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.name, str(i.controls)) table.add_row(i.fullname(), i.club ,str(i.card), i.o_class.name, i.status())
console = Console() console = Console()
console.print(table) console.print(table)
@ -131,17 +131,19 @@ def main():
args = parser.parse_args() args = parser.parse_args()
if args.command == 'show_runners': if args.command == 'show_runners':
courses = otime.courses_from_ttime_conf(args.ttcnf) event = otime.event(0, 'NoName')
o_classes = otime.classes_from_ttime_conf(args.ttcnf, courses) event.import_ttime_cnf(args.ttcnf)
runner_list = otime.ttime_db_to_class(args.ttdb, o_classes) event.import_ttime_db(args.ttdb)
otime.ttime_mtr_to_class(args.mtr, runner_list) event.import_mtr_file(args.mtr)
print_runners(runner_list) event.match_runners_cards()
print_runners(event.runners)
elif args.command == 'show_runner': elif args.command == 'show_runner':
courses = otime.courses_from_ttime_conf(args.ttcnf) event = otime.event(0, 'NoName')
o_classes = otime.classes_from_ttime_conf(args.ttcnf, courses) event.import_ttime_cnf(args.ttcnf)
runner_list = otime.ttime_db_to_class(args.ttdb, o_classes) event.import_ttime_db(args.ttdb)
otime.ttime_mtr_to_class(args.mtr, runner_list) event.import_mtr_file(args.mtr)
for n in runner_list: event.match_runners_cards()
for n in event.runners:
if args.runner == n.fullname(): if args.runner == n.fullname():
inspect(n) inspect(n)
break break

View File

@ -177,6 +177,8 @@ class card_punch:
cards = [] cards = []
# hver rad er brikkenummer med tilhørende info # hver rad er brikkenummer med tilhørende info
for row in csvreader: for row in csvreader:
if len(row) == 0:
continue
rows.append(row) rows.append(row)
controls = [] controls = []
splits = [] 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=';',) csvreader = csv.reader(open(ttime_file, 'r', encoding='latin_1'), delimiter=';',)
runnerarray = [] runnerarray = []
for row in csvreader: for row in csvreader:
if len(row) == 0:
continue
eventorid = row[0] eventorid = row[0]
country = '' country = ''
name = row[2].split(',') name = row[2].split(',')