Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
add constants for each data source to remove magic strings
  • Loading branch information
hughie-coles committed Aug 15, 2021
commit 997ed85dcffe4f24af2a3aba629f123176bf8d1d
11 changes: 8 additions & 3 deletions app/services/location/locationservicefactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
from ..location.nyt import NYTLocationService


NEW_YORK_TIMES = 'nyt'
JOHNS_HOPKINS_UNIVERSITY = 'jhu'
CSBS = 'csbs'


class LocationServiceFactory:
def create(location_service_name):
lowercase_service_name = location_service_name.lower()
if lowercase_service_name == 'csbs':
if lowercase_service_name == CSBS:
return CSBSLocationService()
elif lowercase_service_name == 'jhu':
elif lowercase_service_name == JOHNS_HOPKINS_UNIVERSITY:
return JhuLocationService()
elif lowercase_service_name == 'nyt':
elif lowercase_service_name == NEW_YORK_TIMES:
return NYTLocationService()