diff --git a/dev.py b/dev.py index a293163..53d5aea 100644 --- a/dev.py +++ b/dev.py @@ -7,9 +7,10 @@ from rich.table import Table if __name__ == "__main__": event = otime.event(0, 'supercup') - event.import_ttime_cnf('sc_2021_ttime/ttime.cnf.txt') - event.import_ttime_db('sc_2021_ttime/db_eventor.csv') - event.import_mtr_file('sc_2021_ttime/mtr.csv') + 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.get_xml_res().write('Resultater.xml') + event.create_start_list_pdf('starttimes.pdf') + #event.get_xml_res().write('Resultater.xml') diff --git a/otime.py b/otime.py index 92acd2c..160e5e4 100644 --- a/otime.py +++ b/otime.py @@ -3,6 +3,7 @@ import datetime import csv import re import xml.etree.ElementTree as ET +from fpdf import FPDF class event: def __init__(self, eventid, name, **kwargs): @@ -127,6 +128,25 @@ class event: # ET.indent(root, space=' ', level=0) return tree + + def create_start_list_pdf(self, file_name): + pdf = FPDF() + pdf.add_page() + pdf.add_font("DejaVuSans", fname="/usr/share/fonts/dejavu-sans-fonts/DejaVuSans.ttf") + pdf.set_font("DejaVuSans", size=10) + line_height = pdf.font_size * 2 + col_width = pdf.epw / 4 # distribute content evenly + for runner in self.runners: + pdf.multi_cell(col_width, line_height, runner.fullname(), border=1, ln=3, max_line_height=pdf.font_size, align='L') + pdf.multi_cell(col_width, line_height, runner.o_class.name, border=1, ln=3, max_line_height=pdf.font_size) + pdf.multi_cell(col_width, line_height, str(runner.card), border=1, ln=3, max_line_height=pdf.font_size) + if runner.start_time != None: + pdf.multi_cell(col_width, line_height, str(runner.start_time), border=1, ln=3, max_line_height=pdf.font_size) + else: + pdf.multi_cell(col_width, line_height, '', border=1, ln=3, max_line_height=pdf.font_size) + pdf.ln(line_height) + pdf.output(file_name) + class runner: def __init__(self, runner_id, first, last, club, country, card, o_class, start_time): self.id = runner_id