70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
#!/usr/bin/env python
|
|
import otime
|
|
import pickle
|
|
import asyncio
|
|
from difflib import Differ
|
|
from watchgod import awatch
|
|
from config import config
|
|
from rich import print
|
|
from rich import inspect
|
|
from rich.console import Console
|
|
from rich.columns import Columns
|
|
from rich.table import Table
|
|
|
|
def start():
|
|
global event
|
|
event = otime.event(0, config['event_name'])
|
|
event.import_ttime_cnf('/home/trygve/Documents/sprintcup040330/sprintcup040330.cnf')
|
|
event.import_ttime_db(config['db_file'])
|
|
event.import_mtr_file('/home/trygve/Documents/sprintcup040330/sprintcup040330.log')
|
|
event.match_runners_cards()
|
|
#event.get_xml_res().write(config['xml_res_file'])
|
|
global db_file
|
|
global db_file_u
|
|
db_file = open(config['db_file'], 'r', encoding='latin_1').read().splitlines()
|
|
|
|
async def main():
|
|
async for changes in awatch(config['db_file']):
|
|
#print(dir(changes))
|
|
#print(changes.difference()
|
|
global event
|
|
global db_file
|
|
global db_file_u
|
|
db_file_u = open(config['db_file'], 'r', encoding='latin_1').read().splitlines()
|
|
d = Differ()
|
|
result = list(d.compare(db_file, db_file_u))
|
|
db_file = db_file_u
|
|
|
|
for line in result:
|
|
if line[:1] == '+':
|
|
print(line)
|
|
clean = str(line).replace('+ ', '').split(';')
|
|
runner = otime.runner.from_string(clean, event.o_classes)
|
|
inspect(runner)
|
|
for i, n in enumerate(event.runners):
|
|
if n.id == runner.id:
|
|
inspect(n)
|
|
event.runners[i] = runner
|
|
inspect(n)
|
|
event.match_runners_cards()
|
|
inspect(n)
|
|
|
|
elif line[:1] == '-':
|
|
print(line)
|
|
print('MINUS')
|
|
clean = str(line).replace('- ', '').split(';')
|
|
r_id = clean[1]
|
|
print(r_id)
|
|
for i, n in enumerate(event.runners):
|
|
if n.id == r_id:
|
|
inspect(n)
|
|
print(len(event.runners))
|
|
event.runners.remove(n)
|
|
print(len(event.runners))
|
|
|
|
|
|
db_file_u = None
|
|
if __name__ == "__main__":
|
|
start()
|
|
asyncio.run(main())
|