Skip to content

Commit a15d421

Browse files
authored
Merge pull request #132 from ExpDev07/csbs-location-own-file
moved CSBSLocation to own file
2 parents fab4bdc + ec9212e commit a15d421

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

app/location/__init__.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,35 +92,5 @@ def serialize(self, timelines = False):
9292
key: value.serialize() for (key, value) in self.timelines.items()
9393
}})
9494

95-
# Return the serialized location.
96-
return serialized
97-
98-
class CSBSLocation(Location):
99-
"""
100-
A CSBS (county) location.
101-
"""
102-
def __init__(self, id, state, county, coordinates, last_updated, confirmed, deaths):
103-
super().__init__(
104-
id, 'US', county, coordinates, last_updated, confirmed, deaths, recovered=0
105-
)
106-
107-
self.state = state
108-
self.county = county
109-
110-
def serialize(self, timelines=False):
111-
"""
112-
Serializes the location into a dict.
113-
114-
:returns: The serialized location.
115-
:rtype: dict
116-
"""
117-
serialized = super().serialize()
118-
119-
# Update with new fields.
120-
serialized.update({
121-
'state': self.state,
122-
'county': self.county,
123-
})
124-
12595
# Return the serialized location.
12696
return serialized

app/location/csbs.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from . import Location
2+
3+
class CSBSLocation(Location):
4+
"""
5+
A CSBS (county) location.
6+
"""
7+
def __init__(self, id, state, county, coordinates, last_updated, confirmed, deaths):
8+
super().__init__(
9+
# General info.
10+
id, 'US', state, coordinates, last_updated,
11+
12+
# Statistics.
13+
confirmed=confirmed,
14+
deaths=deaths,
15+
recovered=0
16+
)
17+
18+
self.state = state
19+
self.county = county
20+
21+
def serialize(self, timelines=False):
22+
"""
23+
Serializes the location into a dict.
24+
25+
:returns: The serialized location.
26+
:rtype: dict
27+
"""
28+
serialized = super().serialize()
29+
30+
# Update with new fields.
31+
serialized.update({
32+
'state': self.state,
33+
'county': self.county,
34+
})
35+
36+
# Return the serialized location.
37+
return serialized

app/services/location/csbs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from . import LocationService
2-
from ...location import CSBSLocation
32
from ...coordinates import Coordinates
3+
from ...location.csbs import CSBSLocation
44

55
class CSBSLocationService(LocationService):
66
"""

0 commit comments

Comments
 (0)