Småforbedringer
This commit is contained in:
parent
056b97c0e2
commit
95f10000bb
@ -16,7 +16,7 @@ def create_result_file(event, file_path, o_classes=[]):
|
|||||||
root.set('iofVersion', '3.0')
|
root.set('iofVersion', '3.0')
|
||||||
root.set('createTime', datetime.datetime.now().isoformat(timespec='seconds'))
|
root.set('createTime', datetime.datetime.now().isoformat(timespec='seconds'))
|
||||||
root.set('creator', 'oTime')
|
root.set('creator', 'oTime')
|
||||||
root.set('status', 'Complete')
|
#root.set('status', 'Complete')
|
||||||
tree = ET.ElementTree(root)
|
tree = ET.ElementTree(root)
|
||||||
xml_event = ET.SubElement(root, 'Event')
|
xml_event = ET.SubElement(root, 'Event')
|
||||||
xml_child(xml_event, 'Id', event.id)
|
xml_child(xml_event, 'Id', event.id)
|
||||||
|
@ -94,7 +94,7 @@ class CardDump:
|
|||||||
splits.append(time)
|
splits.append(time)
|
||||||
|
|
||||||
# Extract start time:
|
# Extract start time:
|
||||||
year = int.from_bytes(datamsg[8:9], 'little')
|
year = 2000 + int.from_bytes(datamsg[8:9], 'little')
|
||||||
month = int.from_bytes(datamsg[9:10], 'little')
|
month = int.from_bytes(datamsg[9:10], 'little')
|
||||||
day = int.from_bytes(datamsg[10:11], 'little')
|
day = int.from_bytes(datamsg[10:11], 'little')
|
||||||
hours = int.from_bytes(datamsg[11:12], 'little')
|
hours = int.from_bytes(datamsg[11:12], 'little')
|
||||||
@ -182,7 +182,7 @@ class OClass:
|
|||||||
|
|
||||||
class RunnerResult:
|
class RunnerResult:
|
||||||
def __init__(self, runner_id: int, first: str, last: str, status: str, place: int, total_time: int, splits: list[int], end_time,
|
def __init__(self, runner_id: int, first: str, last: str, status: str, place: int, total_time: int, splits: list[int], end_time,
|
||||||
club=None, club_id=None, country=None, card_id=None, o_class=None, controls=None, fork=0, start_time=None, fee_id=None):
|
club=None, club_id=None, country=None, card_id=None, o_class=None, controls=None, fork=0, start_time=datetime.datetime(1973, 1, 1), fee_id=None):
|
||||||
self.id = runner_id
|
self.id = runner_id
|
||||||
self.first = first
|
self.first = first
|
||||||
self.last = last
|
self.last = last
|
||||||
@ -268,13 +268,17 @@ class Event:
|
|||||||
if not o_class:
|
if not o_class:
|
||||||
return 'Inactive'
|
return 'Inactive'
|
||||||
course = self.get_course(o_class.course)
|
course = self.get_course(o_class.course)
|
||||||
if self.get_card_dump(runner.card_id) == None:
|
if not self.get_card_dump(runner.card_id):
|
||||||
return 'Active'
|
return 'Active'
|
||||||
if contains(course.codes, self.get_card_dump(runner.card_id).controls):
|
if contains(course.codes, self.get_card_dump(runner.card_id).controls):
|
||||||
return 'OK'
|
return 'OK'
|
||||||
else:
|
else:
|
||||||
return 'MissingPunch'
|
return 'MissingPunch'
|
||||||
|
|
||||||
|
def get_runner_result(self, runner_id):
|
||||||
|
runner = self.get_runner(runner_id)
|
||||||
|
return next((i for i in produce_class_result(self, runner.o_class).runner_results if i.id == runner_id), None)
|
||||||
|
|
||||||
def get_runner_time(self, id):
|
def get_runner_time(self, id):
|
||||||
runner = self.get_runner(id)
|
runner = self.get_runner(id)
|
||||||
card_dump = self.get_card_dump(runner.card_id)
|
card_dump = self.get_card_dump(runner.card_id)
|
||||||
@ -331,7 +335,7 @@ class Event:
|
|||||||
def get_result(self, o_classes: list[str] = []) -> list[ClassResult]:
|
def get_result(self, o_classes: list[str] = []) -> list[ClassResult]:
|
||||||
if not o_classes:
|
if not o_classes:
|
||||||
o_classes = [i.name for i in self.o_classes]
|
o_classes = [i.name for i in self.o_classes]
|
||||||
return [produce_class_result(copy.deepcopy(self), i) for i in o_classes]
|
return [produce_class_result(self, i) for i in o_classes]
|
||||||
|
|
||||||
def read_xml_entries(self, xml_file):
|
def read_xml_entries(self, xml_file):
|
||||||
self.add_runners(*runners_from_xml_entries(xml_file))
|
self.add_runners(*runners_from_xml_entries(xml_file))
|
||||||
@ -379,11 +383,11 @@ def produce_class_result(event, o_class_name) -> ClassResult:
|
|||||||
other_runners = [i for i in runners if i not in ok_runners and i not in dsq_runners]
|
other_runners = [i for i in runners if i not in ok_runners and i not in dsq_runners]
|
||||||
|
|
||||||
results = [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), ok_runners.index(i)+1, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
results = [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), ok_runners.index(i)+1, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
||||||
event.get_runner_end_clock(i.id), i.club, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id), start_time=event.get_card_dump(i.card_id).s_time) for i in ok_runners]
|
event.get_runner_end_clock(i.id), i.club, 0, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id), start_time=event.get_card_dump(i.card_id).s_time) for i in ok_runners]
|
||||||
results += [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
results += [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
||||||
event.get_runner_end_clock(i.id), i.club, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id), start_time=event.get_card_dump(i.card_id).s_time) for i in dsq_runners]
|
event.get_runner_end_clock(i.id), i.club, 0, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id), start_time=event.get_card_dump(i.card_id).s_time) for i in dsq_runners]
|
||||||
results += [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
results += [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
||||||
event.get_runner_end_clock(i.id), i.club, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id)) for i in other_runners]
|
event.get_runner_end_clock(i.id), i.club, 0, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id)) for i in other_runners]
|
||||||
|
|
||||||
return ClassResult(o_class.name, event.get_course(o_class.course), results)
|
return ClassResult(o_class.name, event.get_course(o_class.course), results)
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ def create_result_list(event, file_path, o_classes=[]):
|
|||||||
|
|
||||||
pdf = FPDF()
|
pdf = FPDF()
|
||||||
pdf.add_page()
|
pdf.add_page()
|
||||||
pdf.add_font("LiberationSans", fname="../../otime/data/fonts/LiberationSans-Regular.ttf")
|
pdf.add_font("LiberationSans", fname="otime/data/fonts/LiberationSans-Regular.ttf")
|
||||||
pdf.set_font("LiberationSans", size=10)
|
pdf.set_font("LiberationSans", size=10)
|
||||||
line_height = pdf.font_size * 1.5
|
line_height = pdf.font_size * 1.5
|
||||||
col_width = pdf.epw / 4 # distribute content evenly
|
col_width = pdf.epw / 4 # distribute content evenly
|
||||||
@ -38,7 +38,7 @@ def create_split_result_list(event, file_path, o_classes=[]):
|
|||||||
|
|
||||||
pdf = FPDF()
|
pdf = FPDF()
|
||||||
pdf.add_page(orientation='L')
|
pdf.add_page(orientation='L')
|
||||||
pdf.add_font("LiberationSans", fname="../../otime/data/fonts/LiberationSans-Regular.ttf")
|
pdf.add_font("LiberationSans", fname="otime/data/fonts/LiberationSans-Regular.ttf")
|
||||||
pdf.set_font("LiberationSans", size=8)
|
pdf.set_font("LiberationSans", size=8)
|
||||||
line_height = pdf.font_size * 1.5
|
line_height = pdf.font_size * 1.5
|
||||||
col_width = pdf.epw / 4 # distribute content evenly
|
col_width = pdf.epw / 4 # distribute content evenly
|
||||||
|
Loading…
Reference in New Issue
Block a user