2121PID = os .getpid ()
2222
2323
24- class JhuLocationService ( LocationService ) :
24+ class JhuLocationService :
2525 """
2626 Service for retrieving locations from Johns Hopkins CSSE (https://github.com/CSSEGISandData/COVID-19).
2727 """
28-
29- async def get_all (self ):
30- # Get the locations.
31- locations = await get_locations ()
32- return locations
33-
34- async def get (self , loc_id ): # pylint: disable=arguments-differ
35- # Get location at the index equal to provided id.
36- locations = await self .get_all ()
37- return locations [loc_id ]
38-
39-
40- # ---------------------------------------------------------------
41-
42-
43- # Base URL for fetching category.
44- BASE_URL = "https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/csse_covid_19_data/csse_covid_19_time_series/"
28+ # Base URL for fetching category.
29+ BASE_URL = "https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/csse_covid_19_data/csse_covid_19_time_series/"
4530
4631
4732@cached (cache = TTLCache (maxsize = 4 , ttl = 1800 ))
@@ -82,10 +67,12 @@ async def get_category(category):
8267
8368 for item in data :
8469 # Filter out all the dates.
85- dates = dict (filter (lambda element : date_util .is_date (element [0 ]), item .items ()))
70+ dates = dict (
71+ filter (lambda element : date_util .is_date (element [0 ]), item .items ()))
8672
8773 # Make location history from dates.
88- history = {date : int (float (amount or 0 )) for date , amount in dates .items ()}
74+ history = {date : int (float (amount or 0 ))
75+ for date , amount in dates .items ()}
8976
9077 # Country for this location.
9178 country = item ["Country/Region" ]
@@ -101,7 +88,7 @@ async def get_category(category):
10188 "country_code" : countries .country_code (country ),
10289 "province" : item ["Province/State" ],
10390 # Coordinates.
104- "coordinates" : {"lat" : item ["Lat" ], "long" : item ["Long" ],},
91+ "coordinates" : {"lat" : item ["Lat" ], "long" : item ["Long" ], },
10592 # History.
10693 "history" : history ,
10794 # Latest statistic.
@@ -178,7 +165,8 @@ async def get_locations():
178165 location ["country" ],
179166 location ["province" ],
180167 # Coordinates.
181- Coordinates (latitude = coordinates ["lat" ], longitude = coordinates ["long" ]),
168+ Coordinates (
169+ latitude = coordinates ["lat" ], longitude = coordinates ["long" ]),
182170 # Last update.
183171 datetime .utcnow ().isoformat () + "Z" ,
184172 # Timelines (parse dates as ISO).
0 commit comments