Skip to content

Commit 1b3141b

Browse files
committed
add location factory
1 parent 1c7e4ae commit 1b3141b

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

app/data/__init__.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
"""app.data"""
2-
from ..services.location.csbs import CSBSLocationService
3-
from ..services.location.jhu import JhuLocationService
4-
from ..services.location.nyt import NYTLocationService
5-
6-
# Mapping of services to data-sources.
7-
DATA_SOURCES = {
8-
"jhu": JhuLocationService(),
9-
"csbs": CSBSLocationService(),
10-
"nyt": NYTLocationService(),
11-
}
12-
2+
from ..services.location.location_factory import LocationFactory
133

144
def data_source(source):
155
"""
@@ -18,4 +8,4 @@ def data_source(source):
188
:returns: The service.
199
:rtype: LocationService
2010
"""
21-
return DATA_SOURCES.get(source.lower())
11+
return LocationFactory.get_location(source)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""app.services.location.location_factory.py"""
2+
3+
class LocationFactory:
4+
def get_location(source):
5+
if source == 'csbs':
6+
return CSBSLocationService()
7+
8+
elif source == 'nyt'
9+
return NYTLocationService()
10+
11+
elif source == 'jhu':
12+
return JhuLocationService()

0 commit comments

Comments
 (0)