Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions app/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
"""app.data"""
from ..services.location.csbs import CSBSLocationService
from ..services.location.jhu import JhuLocationService
from ..services.location.nyt import NYTLocationService

# Mapping of services to data-sources.
DATA_SOURCES = {
"jhu": JhuLocationService(),
"csbs": CSBSLocationService(),
"nyt": NYTLocationService(),
}

from ..services.location.location_factory import LocationFactory

def data_source(source):
"""
Expand All @@ -18,4 +8,4 @@ def data_source(source):
:returns: The service.
:rtype: LocationService
"""
return DATA_SOURCES.get(source.lower())
return LocationFactory.get_location(source)
12 changes: 12 additions & 0 deletions app/services/location/location_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""app.services.location.location_factory.py"""

class LocationFactory:
def get_location(source):
if source == 'csbs':
return CSBSLocationService()

elif source == 'nyt'
return NYTLocationService()

elif source == 'jhu':
return JhuLocationService()