-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscorecards.py
104 lines (98 loc) · 4 KB
/
scorecards.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from anker_scorecards_python import anker_scorecards, blank_scorecards
def CSVForScorecards(scheduleInfo,personInfo,combined):
header = 'Name,Id'
mbldDone = False
if combined:
combHy = combined[0]+'-'+combined[1]
for event in scheduleInfo.events:
if combined:
if event[0] == combHy:
for event in event[0].split('-'):
header+=f',{event}'
elif scheduleInfo.mbldCounter and not mbldDone:
if event[0][:-1] == '333mbf':
mbldDone = True
header+=',333mbf'
else:
header+=f',{event[0]}'
elif event[0][:-1] != '333mbf':
header+=f',{event[0]}'
else:
if scheduleInfo.mbldCounter and not mbldDone:
if event[0][:-1] == '333mbf':
mbldDone = True
header+=',333mbf'
else:
header+=f',{event[0]}'
elif event[0][:-1] != '333mbf':
header+=f',{event[0]}'
hCSV = header.split(',')
header+='\n'
# personlist = [val[0] for val in sorted(personInfo.items(),key= lambda x:x[1].id)] # should not be needed, as it should be sorted already
for person in personInfo:
pString = str(person) + ',' + str(personInfo[person].id)
for event in hCSV[1:]:
if event in personInfo[person].groups:
pString+=f"{personInfo[person].groups[event]};{personInfo[person].stationNumbers[event]}"
elif mbldDone and event =='333mbf' and '333mbf1' in personInfo[person].groups:
pString+=f"{personInfo[person].groups['333mbf1']};{personInfo[person].stationNumbers['333mbf1']}"
pString+=','
pString = pString[:-1]
header+=pString+'\n'
return header
def CSVForTimeLimits(scheduleInfo,combined):
header = ''
mbldDone = False
if combined:
combHy = combined[0]+'-'+combined[1]
for event in scheduleInfo.events:
if combined:
if event[0] == combHy:
for event in event[0].split('-'):
header+=f',{event}'
elif scheduleInfo.mbldCounter and not mbldDone:
if event[0][:-1] == '333mbf':
mbldDone = True
header+=',333mbf'
else:
header+=f',{event[0]}'
elif event[0][:-1] != '333mbf':
header+=f',{event[0]}'
else:
if scheduleInfo.mbldCounter and not mbldDone:
if event[0][:-1] == '333mbf':
mbldDone = True
header+=',333mbf'
else:
header+=f',{event[0]}'
elif event[0][:-1] != '333mbf':
header+=f',{event[0]}'
header = header[1:]
hCSV = header.split(',')
header+='\n'
for event in hCSV:
t, c = scheduleInfo.timelimits[event]
if t:
if (not t['cumulativeRoundIds']) and (not c):
header += f"T;{t['centiseconds']},"
elif len(t['cumulativeRoundIds']) > 1:
eventstring = ''
for tlevent in t['cumulativeRoundIds']:
eventstring += f";{tlevent.split('-')[0]}"
header += f"S;{t['centiseconds']}{eventstring}," # HHHHH
elif t['cumulativeRoundIds']:
for tlevent in t['cumulativeRoundIds']:
eventstring = f"{tlevent.split('-')[0]}"
header += f"C;{t['centiseconds']},"
elif c:
header += f"K;{c['attemptResult']};{t['centiseconds']},"
else: # multi bld
header += f"M,"
header = header[:-1]
return header
def genScorecards(groups,tls,compname,no_stages,am_stages,sort_by_name):
fileAnker = anker_scorecards(groups,tls,compname,no_stages,am_stages,sort_by_name)
return bytearray(fileAnker)
def getBlanks(compname):
blanks = blank_scorecards(compname)
return bytearray(blanks)