forked from Trygve/otime
Tilbakemelding når db fila oppdateres
This commit is contained in:
parent
aee7271cf8
commit
6289690149
17
event_mgr.py
17
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'])
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user