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
Next Next commit
Update __init__.py
  • Loading branch information
ashnaw authored Jul 24, 2021
commit 51ebbe4af0e7d606e46b2f881f4c63d4f45e7824
9 changes: 3 additions & 6 deletions app/location/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""app.location"""
from ..coordinates import Coordinates
from ..utils import countries
from ..utils.countries import CountryCodeUtil
from ..utils.populations import country_population


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

def __init__(
self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered,
Expand All @@ -31,17 +32,15 @@ def __init__(
def country_code(self):
"""
Gets the alpha-2 code represention of the country. Returns 'XX' if none is found.

:returns: The country code.
:rtype: str
"""
return (countries.country_code(self.country) or countries.DEFAULT_COUNTRY_CODE).upper()
return (country_code_util.get_country_code(self.country) or country_code_util.DEFAULT_COUNTRY_CODE).upper()

@property
def country_population(self):
"""
Gets the population of this location.

:returns: The population.
:rtype: int
"""
Expand All @@ -50,7 +49,6 @@ def country_population(self):
def serialize(self):
"""
Serializes the location into a dict.

:returns: The serialized location.
:rtype: dict
"""
Expand Down Expand Up @@ -101,7 +99,6 @@ def __init__(self, id, country, province, coordinates, last_updated, timelines):
def serialize(self, timelines=False):
"""
Serializes the location into a dict.

:param timelines: Whether to include the timelines.
:returns: The serialized location.
:rtype: dict
Expand Down