-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCore.py
executable file
·46 lines (41 loc) · 1.1 KB
/
Core.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
import csv
class Core:
model = 'none'
leg = 0.0
def __init__(self, supplier, model, a, b, leg, d, e, f, g):
self.supplier = supplier
self.model = model
self.leg = float(leg)
self.a = float(a)
self.b = float(b)
self.c = float(leg)
self.d = float(d)
self.e = float(e)
self.f = float(f)
self.g = float(g)
def __repr__(self):
return self.supplier + ":" + self.model + ": leg=" + str(self.leg) + " mm"
@staticmethod
def load(file):
table = []
with open(file) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
for row in csv_reader:
if line_count == 0:
# print(f'Column names: {", ".join(row)}')
line_count += 1
else:
bob = Core(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8])
table.append(bob)
# print(f'\t{row[0]}: code="{row[1]}"", leg={row[2]} mm')
line_count += 1
# print(f'Processed {line_count} lines.')
return table
@staticmethod
def lookupCoresBySize(cores, lmin, lmax):
resp = []
for c in cores:
if c.leg >= lmin and c.leg <= lmax:
resp.append(c)
return resp