Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
47 changes: 25 additions & 22 deletions app/location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,14 @@
from ..utils import countries
from ..utils.populations import country_population

class Country:
def __init__(self, id, country, province, coordinates):

# pylint: disable=redefined-builtin,invalid-name
class Location: # pylint: disable=too-many-instance-attributes
"""
A location in the world affected by the coronavirus.
"""

def __init__(
self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered,
): # pylint: disable=too-many-arguments
# General info.
self.id = id
self.country = country.strip()
self.province = province.strip()
self.coordinates = coordinates

# Last update.
self.last_updated = last_updated

# Statistics.
self.confirmed = confirmed
self.deaths = deaths
self.recovered = recovered


@property
def country_code(self):
"""
Expand All @@ -47,13 +31,31 @@ def country_population(self):
"""
return country_population(self.country_code)


# pylint: disable=redefined-builtin,invalid-name
class Location: # pylint: disable=too-many-instance-attributes
"""
A location in the world affected by the coronavirus.
"""

def __init__(self, last_updated, confirmed, deaths, recovered): # pylint: disable=too-many-arguments

# Last update.
self.last_updated = last_updated

# Statistics.
self.confirmed = confirmed
self.deaths = deaths
self.recovered = recovered

def serialize(self):
"""
Serializes the location into a dict.

:returns: The serialized location.
:rtype: dict
"""

return {
# General info.
"id": self.id,
Expand All @@ -74,14 +76,14 @@ def serialize(self):
}


class TimelinedLocation(Location):
class TimelinedLocation:
"""
A location with timelines.
"""

# pylint: disable=too-many-arguments
def __init__(self, id, country, province, coordinates, last_updated, timelines):
super().__init__(
def __init__(self, id, country, province, coordinates, last_updated, timelines, location):
Location.__init__(
# General info.
id,
country,
Expand All @@ -96,6 +98,7 @@ def __init__(self, id, country, province, coordinates, last_updated, timelines):

# Set timelines.
self.timelines = timelines
self.location = Location

# pylint: disable=arguments-differ
def serialize(self, timelines=False):
Expand Down
8 changes: 5 additions & 3 deletions app/location/csbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from . import Location


class CSBSLocation(Location):
class CSBSLocation:
"""
A CSBS (county) location.
"""

# pylint: disable=too-many-arguments,redefined-builtin
def __init__(self, id, state, county, coordinates, last_updated, confirmed, deaths):
super().__init__(
def __init__(self, id, state, county, coordinates, last_updated, confirmed, deaths, location):
Location.__init__(
# General info.
id,
"US",
Expand All @@ -24,6 +24,8 @@ def __init__(self, id, state, county, coordinates, last_updated, confirmed, deat

self.state = state
self.county = county
self.location = Location


def serialize(self, timelines=False): # pylint: disable=arguments-differ,unused-argument
"""
Expand Down
7 changes: 4 additions & 3 deletions app/location/nyt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
from . import TimelinedLocation


class NYTLocation(TimelinedLocation):
class NYTLocation:
"""
A NYT (county) Timelinedlocation.
"""

# pylint: disable=too-many-arguments,redefined-builtin
def __init__(self, id, state, county, coordinates, last_updated, timelines):
super().__init__(id, "US", state, coordinates, last_updated, timelines)
def __init__(self, id, state, county, coordinates, last_updated, timelines, timelinedLocation):
TimelinedLocation.__init__(id, "US", state, coordinates, last_updated, timelines)

self.state = state
self.county = county
self.timelinedLocation = TimelinedLocation

def serialize(self, timelines=False): # pylint: disable=arguments-differ,unused-argument
"""
Expand Down