Skip to content

Commit 9e3556e

Browse files
authored
Making it so that only one data source is instantiated at a time.
In the past, any attempt to use this class would result in all the data sources being instantiated. Now, only the one the user requested or jhu will be used by default.
1 parent 1c7e4ae commit 9e3556e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/data/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
from ..services.location.nyt import NYTLocationService
55

66
# Mapping of services to data-sources.
7+
"""
78
DATA_SOURCES = {
89
"jhu": JhuLocationService(),
910
"csbs": CSBSLocationService(),
1011
"nyt": NYTLocationService(),
1112
}
12-
13+
"""
1314

1415
def data_source(source):
1516
"""
@@ -18,4 +19,11 @@ def data_source(source):
1819
:returns: The service.
1920
:rtype: LocationService
2021
"""
22+
if source = "csbs":
23+
return CSBSLocationService()
24+
elif source = "nyt":
25+
return NYTLocation Service()
26+
else:
27+
return JhuLocationService()
28+
2129
return DATA_SOURCES.get(source.lower())

0 commit comments

Comments
 (0)