11"""app.location"""
22from ..coordinates import Coordinates
3- from ..utils import countries
4- from ..utils .populations import country_population
5-
3+ from ..utils import Country
64
75# pylint: disable=redefined-builtin,invalid-name
86class Location : # pylint: disable=too-many-instance-attributes
@@ -11,12 +9,12 @@ class Location: # pylint: disable=too-many-instance-attributes
119 """
1210
1311 def __init__ (
14- self , id , country , province , coordinates , last_updated , confirmed , deaths , recovered ,
12+ self , id , country , coordinates , last_updated , confirmed , deaths , recovered ,
1513 ): # pylint: disable=too-many-arguments
1614 # General info.
1715 self .id = id
18- self .country = country .strip ()
19- self .province = province .strip ()
16+ self .country = country .name . strip ()
17+ self .province = country . province .strip ()
2018 self .coordinates = coordinates
2119
2220 # Last update.
@@ -27,26 +25,6 @@ def __init__(
2725 self .deaths = deaths
2826 self .recovered = recovered
2927
30- @property
31- def country_code (self ):
32- """
33- Gets the alpha-2 code represention of the country. Returns 'XX' if none is found.
34-
35- :returns: The country code.
36- :rtype: str
37- """
38- return (countries .country_code (self .country ) or countries .DEFAULT_COUNTRY_CODE ).upper ()
39-
40- @property
41- def country_population (self ):
42- """
43- Gets the population of this location.
44-
45- :returns: The population.
46- :rtype: int
47- """
48- return country_population (self .country_code )
49-
5028 def serialize (self ):
5129 """
5230 Serializes the location into a dict.
@@ -57,10 +35,10 @@ def serialize(self):
5735 return {
5836 # General info.
5937 "id" : self .id ,
60- "country" : self .country ,
61- "country_code" : self .country_code ,
62- "country_population" : self .country_population ,
63- "province" : self .province ,
38+ "country" : self .country . name ,
39+ "country_code" : self .country . country_code ,
40+ "country_population" : self .country . country_population ,
41+ "province" : self .country . province ,
6442 # Coordinates.
6543 "coordinates" : self .coordinates .serialize (),
6644 # Last updated.
@@ -80,12 +58,12 @@ class TimelinedLocation(Location):
8058 """
8159
8260 # pylint: disable=too-many-arguments
83- def __init__ (self , id , country , province , coordinates , last_updated , timelines ):
61+ def __init__ (self , id , country , coordinates , last_updated , timelines ):
8462 super ().__init__ (
8563 # General info.
8664 id ,
87- country ,
88- province ,
65+ country . name ,
66+ country . province ,
8967 coordinates ,
9068 last_updated ,
9169 # Statistics (retrieve latest from timelines).
0 commit comments