-
Notifications
You must be signed in to change notification settings - Fork 3
/
load_test_robots.py
80 lines (75 loc) · 2.33 KB
/
load_test_robots.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
# -*- coding: utf-8 -*-
from initialize_registry import load_registry
import registry as r
import csv
def get_id(id_counter, robot_data):
division = robot_data['division']
index = id_counter[division]
id_counter[division] += 1
return division[0] + '_' + str(index)
def run():
load_registry()
division_map = {
'fire fighting high school division': 'high_school',
'fire fighting junior division': 'junior',
'fire fighting senior division': 'senior',
'fire fighting walking division': 'walking'
}
unique_map = {
'unique': True,
'customized': False,
'i am not sure': False
}
versa_valve_map = {
'yes': True,
'no': False
}
fields_index = {
'division': 3,
'name': 4,
'unique': 5,
'versa_valve': 6,
'school': 7
}
with open('robot_list.csv', 'rb') as csvfile:
spamreader = csv.reader(csvfile)
i = 0
id_counter = {
'high_school': 1,
'senior': 1,
'walking': 1,
'junior': 1
}
for row in spamreader:
if i == 0:
i += 1
continue
i += 1
d = {}
if row[fields_index['unique']].strip().lower() == (
'i am not sure, please contact me to discuss'):
continue
for field, index in fields_index.iteritems():
if field == 'division':
d[field] = division_map[row[index].strip().lower()]
elif field == 'unique':
d[field] = unique_map[row[index].strip().lower()]
elif field == 'versa_valve':
d[field] = versa_valve_map[row[index].strip().lower()]
else:
d[field] = row[index]
d['id'] = get_id(id_counter, d)
r.get_registry()['ROBOTS'].record_robot(
division=d['division'],
id=d['id'],
volume=0,
school=d['school'],
name=d['name'],
is_unique=d['unique'],
used_versa_valve=d['versa_valve'],
level=1,
is_disqualified=False,
passed_inspection=False
)
if __name__ == "__main__":
run()