File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 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
144def 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 ).
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments