From 6289690149df73ed3c6abb9fe7d6e1d813d1dd25 Mon Sep 17 00:00:00 2001 From: Trygve Date: Wed, 23 Mar 2022 21:56:18 +0100 Subject: [PATCH] =?UTF-8?q?Tilbakemelding=20n=C3=A5r=20db=20fila=20oppdate?= =?UTF-8?q?res?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event_mgr.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/event_mgr.py b/event_mgr.py index bb78dde..5abe55f 100644 --- a/event_mgr.py +++ b/event_mgr.py @@ -35,9 +35,9 @@ def start_parse(): def start_event(): global event event = otime.event(0, config['event_name']) - event.import_ttime_cnf('/home/trygve/Dokumenter/sprintcup040330/sprintcup040330.cnf') + event.import_ttime_cnf('/home/trygve/Documents/sprintcup040330/sprintcup040330.cnf') event.import_ttime_db(config['db_file']) - event.import_mtr_file('/home/trygve/Dokumenter/sprintcup040330/sprintcup040330.log') + event.import_mtr_file('/home/trygve/Documents/sprintcup040330/sprintcup040330.log') event.match_runners_cards() save(event) global db_file @@ -57,7 +57,6 @@ async def main(): global event global db_file global db_file_u - print(len(event.runners)) db_file_u = open(config['db_file'], 'r', encoding='latin_1').read().splitlines() d = Differ() result = list(d.compare(db_file, db_file_u)) @@ -73,13 +72,16 @@ async def main(): #print(line) clean = str(line).replace('+ ', '').split(';') runner = otime.runner.from_string(clean, event.o_classes) - added_raw.append(runner) + inspect(runner) + if runner.firstname: + added_raw.append(runner) elif line[:1] == '-': #print(line) clean = str(line).replace('- ', '').split(';') runner = otime.runner.from_string(clean, event.o_classes) - removed_raw.append(runner) + if runner.firstname: + removed_raw.append(runner) for plus in added_raw: for index, minus in enumerate(removed_raw): @@ -94,18 +96,21 @@ async def main(): #print(len(added),len(removed),len(changed)) event.runners.extend(added) + for n in added: + print(f'[green]Added: {n.fullname()}, {n.o_class.name}, {n.card}[green]') for r in removed: for n in event.runners: if n.id == r.id: + print(f'[red]Removed: {n.fullname()}, {n.o_class.name}, {n.card}') event.runners.remove(n) for change in changed: for i, n in enumerate(event.runners): if n.id == runner.id: event.runners[i] = runner + print(f'[blue]Changed: {runner.fullname()}, {runner.o_class.name}, {runner.card}') event.match_runners_cards() - print(len(event.runners)) event.get_xml_res().write(config['xml_res_file'])