33from ..utils import countries
44from ..utils .populations import country_population
55
6+ class Statistics :
7+ def __init__ (self , confirmed = 0 , deaths = 0 , recovered = 0 ):
8+ self .__confirmed = confirmed
9+ self .__deaths = deaths
10+ self .__recovered = recovered
11+
12+ @property ()
13+ def confirmed (self ):
14+ return self .__confirmed
15+
16+ @confirmed .setter
17+ def confirmed (self , value ):
18+ self .__confirmed = value
19+
20+ @property ()
21+ def deaths (self ):
22+ return self .__deaths
23+
24+ @deaths .setter
25+ def deaths (self , value ):
26+ self .__deaths = value
27+
28+ @property ()
29+ def recovered (self ):
30+ return self .__recovered
31+
32+ @recovered .setter
33+ def recovered (self , value ):
34+ self .__recovered = value
635
736# pylint: disable=redefined-builtin,invalid-name
837class Location : # pylint: disable=too-many-instance-attributes
@@ -11,7 +40,7 @@ class Location: # pylint: disable=too-many-instance-attributes
1140 """
1241
1342 def __init__ (
14- self , id , country , province , coordinates , last_updated , confirmed , deaths , recovered ,
43+ self , id , country , province , coordinates , last_updated , statistics
1544 ): # pylint: disable=too-many-arguments
1645 # General info.
1746 self .id = id
@@ -23,9 +52,7 @@ def __init__(
2352 self .last_updated = last_updated
2453
2554 # Statistics.
26- self .confirmed = confirmed
27- self .deaths = deaths
28- self .recovered = recovered
55+ self .statistics = statistics
2956
3057 @property
3158 def country_code (self ):
@@ -67,9 +94,9 @@ def serialize(self):
6794 "last_updated" : self .last_updated ,
6895 # Latest data (statistics).
6996 "latest" : {
70- "confirmed" : self .confirmed ,
71- "deaths" : self .deaths ,
72- "recovered" : self .recovered ,
97+ "confirmed" : self .statistics . confirmed ,
98+ "deaths" : self .statistics . deaths ,
99+ "recovered" : self .statistics . recovered ,
73100 },
74101 }
75102
@@ -80,7 +107,7 @@ class TimelinedLocation(Location):
80107 """
81108
82109 # pylint: disable=too-many-arguments
83- def __init__ (self , id , country , province , coordinates , last_updated , timelines ):
110+ def __init__ (self , id , country , province , coordinates , last_updated , statistics , timelines ):
84111 super ().__init__ (
85112 # General info.
86113 id ,
@@ -89,11 +116,11 @@ def __init__(self, id, country, province, coordinates, last_updated, timelines):
89116 coordinates ,
90117 last_updated ,
91118 # Statistics (retrieve latest from timelines).
92- confirmed = timelines .get ("confirmed" ).latest or 0 ,
93- deaths = timelines .get ("deaths" ).latest or 0 ,
94- recovered = timelines .get ("recovered" ).latest or 0 ,
119+ statistics
95120 )
96-
121+ self .statistics .confirmed = timelines .get ("confirmed" ).latest or 0
122+ self .statistics .deaths = timelines .get ("deaths" ).latest or 0
123+ self .statistics .recovered = timelines .get ("recovered" ).latest or 0
97124 # Set timelines.
98125 self .timelines = timelines
99126
0 commit comments