Skip to content

Commit 555c1dd

Browse files
author
ExpDev07
committed
formatted
1 parent 635f777 commit 555c1dd

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

app/location/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ def serialize(self):
5252
"""
5353
return {
5454
# General info.
55-
'id' : self.id,
56-
'country' : self.country,
57-
'country_code' : self.country_code,
58-
'country_population': self.country_population,
59-
'province' : self.province,
55+
"id": self.id,
56+
"country": self.country,
57+
"country_code": self.country_code,
58+
"country_population": self.country_population,
59+
"province": self.province,
6060
# Coordinates.
6161
"coordinates": self.coordinates.serialize(),
6262
# Last updated.

app/models/location.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class Location(BaseModel):
1515
country: str
1616
country_code: str
1717
country_population: int = None
18-
province: str = ''
19-
county: str = ''
20-
last_updated: str # TODO use datetime.datetime type.
18+
province: str = ""
19+
county: str = ""
20+
last_updated: str # TODO use datetime.datetime type.
2121
coordinates: Dict
2222
latest: Latest
2323
timelines: Timelines = {}

app/utils/countrycodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,5 +377,5 @@ def country_code(country):
377377
return is_3166_1[country]
378378

379379
# Default to default_code.
380-
print ("No country_code found for '" + country + "'. Using '" + default_code + "'")
380+
print("No country_code found for '" + country + "'. Using '" + default_code + "'")
381381
return default_code

app/utils/populations.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ def fetch_populations():
1212
:returns: The mapping of populations.
1313
:rtype: dict
1414
"""
15-
print ("Fetching populations...")
15+
print("Fetching populations...")
1616

1717
# Mapping of populations
1818
mappings = {}
1919

2020
# Fetch the countries.
21-
countries = requests.get("http://api.geonames.org/countryInfoJSON?username=dperic").json()['geonames']
21+
countries = requests.get("http://api.geonames.org/countryInfoJSON?username=dperic").json()["geonames"]
2222

2323
# Go through all the countries and perform the mapping.
2424
for country in countries:
25-
mappings.update({ country["countryCode"]: int(country["population"]) or None })
25+
mappings.update({country["countryCode"]: int(country["population"]) or None})
2626

2727
# Finally, return the mappings.
2828
return mappings
2929

30+
3031
# Mapping of alpha-2 codes country codes to population.
3132
populations = fetch_populations()
3233

@@ -39,5 +40,3 @@ def country_population(country_code, default=None):
3940
:rtype: int
4041
"""
4142
return populations.get(country_code, default)
42-
43-

tests/test_location.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def __init__(self, latest):
1313

1414
return TestTimeline(args[0])
1515

16+
1617
@pytest.mark.parametrize(
1718
"test_id, country, country_code, province, latitude, longitude, confirmed_latest, deaths_latest, recovered_latest",
1819
[
@@ -39,7 +40,7 @@ def test_location_class(
3940

4041
# Timelines
4142
confirmed = timeline.Timeline(confirmed_latest)
42-
deaths = timeline.Timeline(deaths_latest)
43+
deaths = timeline.Timeline(deaths_latest)
4344
recovered = timeline.Timeline(recovered_latest)
4445

4546
# Date now.
@@ -51,4 +52,4 @@ def test_location_class(
5152
)
5253

5354
assert location_obj.country_code == country_code
54-
assert not location_obj.serialize() == None
55+
assert not location_obj.serialize() == None

0 commit comments

Comments
 (0)