Skip to content

Commit 51ebbe4

Browse files
authored
Update __init__.py
1 parent 1c7e4ae commit 51ebbe4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

app/location/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""app.location"""
22
from ..coordinates import Coordinates
3-
from ..utils import countries
3+
from ..utils.countries import CountryCodeUtil
44
from ..utils.populations import country_population
55

66

@@ -9,6 +9,7 @@ class Location: # pylint: disable=too-many-instance-attributes
99
"""
1010
A location in the world affected by the coronavirus.
1111
"""
12+
country_code_util = CountryCodeUtil()
1213

1314
def __init__(
1415
self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered,
@@ -31,17 +32,15 @@ def __init__(
3132
def country_code(self):
3233
"""
3334
Gets the alpha-2 code represention of the country. Returns 'XX' if none is found.
34-
3535
:returns: The country code.
3636
:rtype: str
3737
"""
38-
return (countries.country_code(self.country) or countries.DEFAULT_COUNTRY_CODE).upper()
38+
return (country_code_util.get_country_code(self.country) or country_code_util.DEFAULT_COUNTRY_CODE).upper()
3939

4040
@property
4141
def country_population(self):
4242
"""
4343
Gets the population of this location.
44-
4544
:returns: The population.
4645
:rtype: int
4746
"""
@@ -50,7 +49,6 @@ def country_population(self):
5049
def serialize(self):
5150
"""
5251
Serializes the location into a dict.
53-
5452
:returns: The serialized location.
5553
:rtype: dict
5654
"""
@@ -101,7 +99,6 @@ def __init__(self, id, country, province, coordinates, last_updated, timelines):
10199
def serialize(self, timelines=False):
102100
"""
103101
Serializes the location into a dict.
104-
105102
:param timelines: Whether to include the timelines.
106103
:returns: The serialized location.
107104
:rtype: dict

0 commit comments

Comments
 (0)