-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.py
66 lines (59 loc) · 1.84 KB
/
data.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
from collections import OrderedDict
colornames = {
"blue": "#3F51B5",
"orange": "#FF9800",
"red": "#D50000",
"green": "#4CAF50",
"bus": "#FFEA00",
"cr": "#9C27B0"
}
routenames = OrderedDict(
[("Red", "Red Line"),
("Mattapan", "Red/Mattapan"),
("Blue", "Blue Line"),
("Orange", "Orange Line"),
("Green-B", "Green Line - B"),
("Green-C", "Green Line - C"),
("Green-D", "Green Line - D"),
("Green-E", "Green Line - E"),
("741", "SL1"),
("742", "SL2"),
("751", "SL4"),
("749", "SL5"),
("CR-Fairmount", "CR Fairmount"),
("CR-Fitchburg", "CR Fitchburg"),
("CR-Worcester", "CR Framingham/Worcester"),
("CR-Franklin", "CR Franklin"),
("CR-Greenbush", "CR Greenbush"),
("CR-Haverhill", "CR Haverhill"),
("CR-Kingston", "CR Kingston/Plymouth"),
("CR-Lowell", "CR Lowell"),
("CR-Middleborough", "CR Middleborough/Lakeville"),
("CR-Needham", "CR Needham"),
("CR-Newburyport", "CR Newburyport/Rockport"),
("CR-Providence", "CR Providence/Stoughton")]
)
bus_prefixes = ('1', '2', '3', '4', '5', '6', '8', '9', 'c')
def names(route):
if route.startswith("CR"):
return "%s Line" % route.split("-")[1]
elif route[0].lower() in bus_prefixes:
return "%s Bus" % (route)
elif route.startswith("Green"):
return routenames.get(route)
else:
result = routenames.get(route)
if result:
return "%s" % result
else:
return "%s Line" % route
def colors(route):
route = str(route).lower()
if route.startswith("green-"):
return colornames['green'] or "#000"
elif route.startswith("cr"):
return colornames['cr']
elif route[0] in bus_prefixes:
return colornames['bus']
else:
return colornames.get(route) or '#646464'