Cli er nå helt porta
This commit is contained in:
parent
77ea1385f9
commit
0160ffaec8
54
cli.py
54
cli.py
@ -47,14 +47,20 @@ def print_class_result(runners, o_class):
|
||||
if o_class:
|
||||
runners = otime.get_runners_in_class(runners, o_class)
|
||||
runners_ok = []
|
||||
runners_dsq = []
|
||||
for n in runners:
|
||||
if n.status() == 'OK':
|
||||
runners_ok.append(n)
|
||||
elif n.status() == 'Disqualified':
|
||||
runners_dsq.append(n)
|
||||
runners_ok.sort(key=lambda x: x.totaltime())
|
||||
|
||||
for i in runners_ok:
|
||||
#if i.status() == 'OK':
|
||||
pos += 1
|
||||
table.add_row(str(pos)+'.',i.fullname(), i.club, str(datetime.timedelta(seconds=i.totaltime())))
|
||||
for i in runners_dsq:
|
||||
table.add_row('Dsq',i.fullname(), i.club, '')
|
||||
|
||||
console = Console()
|
||||
console.print(table)
|
||||
@ -68,15 +74,23 @@ def print_class_splits(runners, o_class):
|
||||
table.add_column(str(i))
|
||||
runners = otime.get_runners_in_class(runners, o_class)
|
||||
runners_ok = []
|
||||
runners_dsq = []
|
||||
for n in runners:
|
||||
if n.status() == 'OK':
|
||||
runners_ok.append(n)
|
||||
elif n.status() == 'Disqualified':
|
||||
runners_dsq.append(n)
|
||||
runners_ok.sort(key=lambda x: x.totaltime())
|
||||
pos = 0
|
||||
for i in runners_ok:
|
||||
splits = i.res_splits().values()
|
||||
pos += 1
|
||||
list_string = map(lambda x:str(datetime.timedelta(seconds=x)), i.res_splits())
|
||||
list_string = map(lambda x:str(datetime.timedelta(seconds=x)), splits)
|
||||
table.add_row(str(pos)+'.', i.fullname(), i.club, *list_string)
|
||||
for i in runners_dsq:
|
||||
splits = i.res_splits().values()
|
||||
list_string = map(lambda x:str(datetime.timedelta(seconds=x)), splits)
|
||||
table.add_row('Dsq', i.fullname(), i.club, *list_string)
|
||||
|
||||
console = Console()
|
||||
console.print(table)
|
||||
@ -120,8 +134,6 @@ def main():
|
||||
|
||||
show_classes = subparsers.add_parser('show_classes', help='show a table of classes')
|
||||
show_classes.add_argument('--ttcnf', required=True, help='ttime configuration file')
|
||||
show_classes.add_argument('--ttdb', required=True, help='ttime db files')
|
||||
show_classes.add_argument('--mtr', required=True, help='mtr csv file')
|
||||
|
||||
create_xml = subparsers.add_parser('create_xml', help='Create xml result file')
|
||||
create_xml.add_argument('--ttcnf', required=True, help='ttime configuration file')
|
||||
@ -152,34 +164,34 @@ def main():
|
||||
|
||||
|
||||
elif args.command == 'show_result':
|
||||
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 o_classes:
|
||||
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.o_classes:
|
||||
if args.o_class_str == n.name:
|
||||
sel_classes = [n]
|
||||
break
|
||||
else:
|
||||
sel_classes = o_classes
|
||||
sel_classes = event.o_classes
|
||||
for o_class in sel_classes:
|
||||
if args.splits:
|
||||
print_class_splits(runner_list, o_class)
|
||||
print_class_splits(event.runners, o_class)
|
||||
else:
|
||||
print_class_result(runner_list, o_class)
|
||||
print_class_result(event.runners, o_class)
|
||||
elif args.command == 'show_classes':
|
||||
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_o_classes(o_classes)
|
||||
event = otime.event(0, 'NoName')
|
||||
event.import_ttime_cnf(args.ttcnf)
|
||||
print_o_classes(event.o_classes)
|
||||
|
||||
elif args.command == 'create_xml':
|
||||
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)
|
||||
otime.gen_xml_result(runner_list, o_classes).write(args.file)
|
||||
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()
|
||||
event.get_xml_res().write(args.file)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user