Compare commits

..

No commits in common. "de96006cdbee86232e5bf8b8cc7004e88433d352" and "6ecf4ea1030a7b363138a633fa408b89e67d4a34" have entirely different histories.

2 changed files with 13 additions and 52 deletions

View File

@ -92,17 +92,10 @@ class Event:
for c in self.courses:
if oc.course_str == c.name:
oc.course = c
def match_runners_fees(self):
for r in self.runners:
for f in self.fees:
if r.fee_id == f.id:
r.fee = f
def match_all(self):
self.match_runners_cards()
self.match_runners_o_classes()
self.match_o_classes_courses()
self.match_runners_fees()
def get_xml_res(self):
root = ET.Element('ResultList')
@ -254,13 +247,13 @@ class Event:
def create_start_list_pdf(self, file_name):
pdf = FPDF()
pdf.add_page()
pdf.add_font("LiberationSans", fname="data/fonts/LiberationSans-Regular.ttf")
pdf.set_font("LiberationSans", size=10)
pdf.add_font("DejaVuSans", fname="/usr/share/fonts/truetype/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_str, border=1, ln=3, max_line_height=pdf.font_size)
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)
@ -269,27 +262,6 @@ class Event:
pdf.ln(line_height)
pdf.output(file_name)
def create_invoices(self, file_name):
pdf = FPDF()
pdf.add_page()
pdf.add_font("LiberationSans", fname="data/fonts/LiberationSans-Regular.ttf")
pdf.set_font("LiberationSans", size=10)
line_height = pdf.font_size * 2
col_width = pdf.epw / 7 # distribute content evenly
for runner in self.runners:
pdf.multi_cell(col_width, line_height, runner.id, border=1, ln=3,max_line_height=pdf.font_size, align='L')
pdf.multi_cell(col_width, line_height, runner.last, border=1, ln=3, max_line_height=pdf.font_size, align='L')
pdf.multi_cell(col_width, line_height, runner.first, border=1, ln=3, max_line_height=pdf.font_size, align='L')
pdf.multi_cell(col_width, line_height, runner.o_class_str, border=1, ln=3, max_line_height=pdf.font_size, align='L')
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.multi_cell(col_width, line_height, str(runner.rank(self.runners)), border=1, ln=3, max_line_height=pdf.font_size)
pdf.ln(line_height)
pdf.output(file_name)
# The runner object stores all the data specific to a runner.
class Runner:
def __init__(self, runner_id, first, last, **kwargs):
@ -337,13 +309,12 @@ class Runner:
self.start_time = None
try:
self.fee_id = kwargs['fee_id']
self.fee_str = kwargs['fee_str']
except KeyError:
self.fee_id = None
self.fee_str = None
try:
self.fee = kwargs['fee']
self.fee_id = kwargs['fee'].id
except KeyError:
self.fee = None
@ -418,13 +389,9 @@ class Runner:
elif self.check_codes() == False:
return 'Disqualified'
# TODO: må forbedres
def rank(self, allrunners):
c_ranked = rank_runners(allrunners, self.o_class)
try:
return c_ranked.index(self) + 1
except ValueError:
return None
def res_codes(self):
if self.o_class.course.forked == False:
@ -474,8 +441,7 @@ class Runner:
'card': self.card,
'o_class_str': self.o_class_str,
'fork' : self.fork,
'start_time': self.start_time,
'fee_id': self.fee_id
'start_time': self.start_time
}
class CardDump:
@ -699,19 +665,14 @@ def runners_from_xml_entries(xml_file):
last = name.find('./{http://www.orienteering.org/datastandard/3.0}Family').text
organisation = p_entry.find('./{http://www.orienteering.org/datastandard/3.0}Organisation')
if organisation is not None:
club_id = organisation.find('./{http://www.orienteering.org/datastandard/3.0}Id').text
club_name = organisation.find('./{http://www.orienteering.org/datastandard/3.0}Name').text
club_name_short = organisation.find('./{http://www.orienteering.org/datastandard/3.0}ShortName').text
country = organisation.find('./{http://www.orienteering.org/datastandard/3.0}Country').attrib['code']
else:
club_id = club_name = club_name_short = country = None
class_el = p_entry.find('./{http://www.orienteering.org/datastandard/3.0}Class')
class_str = class_el.find('./{http://www.orienteering.org/datastandard/3.0}Name').text
fee_id = int(p_entry.find('./{http://www.orienteering.org/datastandard/3.0}AssignedFee/{http://www.orienteering.org/datastandard/3.0}Fee/{http://www.orienteering.org/datastandard/3.0}Id').text)
try:
card = int(p_entry.find('./{http://www.orienteering.org/datastandard/3.0}ControlCard').text)
except AttributeError:
@ -720,7 +681,7 @@ def runners_from_xml_entries(xml_file):
start_time = None
runners.append(Runner(rid, first, last, club=club_name, club_id=club_id,
country=country,card=card, o_class_str=class_str,
start_time=start_time, fee_id=fee_id))
start_time=start_time))
return runners
def fees_from_xml_entries(xml_file):
@ -731,7 +692,7 @@ def fees_from_xml_entries(xml_file):
added_ids = []
fee_objs = []
for fee in allfees:
f_id = int(fee.find('./{http://www.orienteering.org/datastandard/3.0}Id').text)
f_id = fee.find('./{http://www.orienteering.org/datastandard/3.0}Id').text
if f_id not in added_ids:
added_ids.append(f_id)