-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.py
More file actions
178 lines (140 loc) · 6.12 KB
/
data.py
File metadata and controls
178 lines (140 loc) · 6.12 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
'''
Author: Alison
Data Class (Data):
Description: Data class to be used by rest of parking program. Few methods for all needs
Main functionality: Brings together multiple sheets and provides an interface to handle all of them easily
'''
from calendar import MONDAY
from baseInfo import BaseInfo
from weeklyInfo import WeeklyInfo
from resultsInfo import ResultsInfo
from strikesInfo import StrikesInfo
class Data:
def __init__(self):
self.baseInfo = BaseInfo() # create the object, automatically gets info and formats it
self.weeklyInfo = WeeklyInfo() # create the object, automatically gets info and formats it
self.resultsInfo = ResultsInfo() # create the object...
self.strikesInfo = StrikesInfo() # creates the object
self.key = [
'Name',
'Car Size',
'Distance (zipcode)',
'Monday Critical Access',
'Tuesday Critical Access',
'Wednesday Critical Access',
'Thursday Critical Access',
'Friday Critical Access',
'Monday Sports/School Ecs',
'Tuesday Sports/School Ecs',
'Wednesday Sports/School Ecs',
'Thursday Sports/School Ecs',
'Friday Sports/School Ecs',
'Carpool Seniors',
'Carpool Underclassmen',
'First Period Free',
'Last Period Free',
'Parallel Parking',
'Strike History'
]
self.finalData = []
self._formatAllInfo()
# at the end, delete everything on the weekly sheet
def _formatAllInfo(self):
"""Formats all info
"""
self.finalData = []
for person in self.weeklyInfo.getAllInfo():
formattedRow = []
# ignore if not eligible to drive
name = person[1]
# print(name)
if not self.baseInfo.userInfoFound(name): continue
if not(person[2] or self.baseInfo.userEligible(name)): continue # if not eligible, don't include them
# 'Name',
formatName = name[:name.find('@')]
formattedRow.append(formatName)
# 'Car Size',
if self.baseInfo.getCarSize(name): formattedRow.append(1)
else: formattedRow.append(0)
# 'Distance (time)',
zipcode = self.baseInfo.getAddress(name)
formattedRow.append(zipcode)
# 'Monday Critical Access',
if 'Monday' in person[13]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Tuesday Critical Access',
if 'Tuesday' in person[13]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Wednesday Critical Access',
if 'Wednesday' in person[13]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Thursday Critical Access',
if 'Thursday' in person[13]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Friday Critical Access',
if 'Friday' in person[13]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Monday Sports/School Ecs',
if 'Monday' in person[15]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Tuesday Sports/School Ecs',
if 'Tuesday' in person[15]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Wednesday Sports/School Ecs',
if 'Wednesday' in person[15]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Thursday Sports/School Ecs',
if 'Thursday' in person[15]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Friday Sports/School Ecs',
if 'Friday' in person[15]: formattedRow.append(1)
else: formattedRow.append(0)
# 'Carpool Seniors',
info = []
for i in range(3,7+1): # 3 is monday, 7 is friday
if person[i] == '3+': info.append(int(3))
else: info.append(int(person[i]))
formattedRow.append(info)
# 'Carpool Underclassmen',
info = []
for i in range(8,12+1): # 8 is monday, 12 is friday
if person[i] == '3+': info.append(int(3))
else: info.append(int(person[i]))
formattedRow.append(info)
# 'First Period Free',
if self.baseInfo.getFirstPeriod(name): formattedRow.append(1)
else: formattedRow.append(0)
# 'Last Period Free',
if self.baseInfo.getLastPeriod(name): formattedRow.append(1)
else: formattedRow.append(0)
# 'Parallel Parking',
if self.baseInfo.getPara(name): formattedRow.append(1)
else: formattedRow.append(0)
# 'Strike History'
formattedRow.append(self.strikesInfo.userStrikeHistory(name))
self.finalData.append(formattedRow)
def getFormattedInfo(self):
"""Gets all information in a formatted fashion (not ordered by name, but abides by set format in TRUE_WEIGHTS)
Returns:
list[list]: final, formatted data
"""
return self.finalData
def getKey(self):
"""Gets the key
Returns:
list: a list describing the order of the info outputted
"""
return self.key
def loadResults(self, newResults):
"""Given an array of the new parking results, updates the Google sheet
Args:
newResults (list[list]): new parking results
"""
self.resultsInfo.updateSheet(newResults) # that's it!
def main():
data = Data()
# print(data.getKey())
# print(data.getFormattedInfo())
# values = [['hi', 'hi', 'hi', 'hi'], ['hello','hello','hello']]
# data.loadResults(values)
if __name__ == '__main__': main()