import otime
from rich import print
from rich import inspect
from rich.console import Console
from rich.columns import Columns
from rich.table import Table
from pathlib import Path


if __name__ == "__main__":
    event = otime.Event(0, 'Sommercup 2')
    #event.import_ttime_cnf('k2ds/tt.cnf')
    #event.import_ttime_db('k2ds/db.csv')
    #event.import_mtr_file('k2ds/mtr.txt')
    #card_punches = otime.card_punch.list_from_mtr_f('sc_2021_ttime/mtr.csv')
    #event.match_runners_cards()
    #event.create_start_list_pdf('starttimes.pdf')
    #event.get_xml_res().write('Resultater.xml')
    event.import_ttime_cnf(open('/home/trygve/Dokumenter/windows_vm/Sommercup_2023/tt/tt.cnf', encoding='latin-1'))
    event.import_ttime_db(open('/home/trygve/Dokumenter/windows_vm/Sommercup_2023/tt/db.csv', encoding='latin-1'))
    event.import_mtr_file(open('/home/trygve/Dokumenter/windows_vm/Sommercup_2023/tt/mtr.csv', encoding='latin-1').read())
    for n in event.runners:
        print(n.club)
    event.match_runners_cards()
    event.get_xml_res().write('/home/trygve/Dokumenter/windows_vm/Sommercup_2023/tt/Resultater.xml')
    for n in event.card_dumps:
        print(n.card, n.controls)