Skip to content
Closed
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Changing the files which inheirt from CreationalBP interface to imita…
…te logic of factory pattern
  • Loading branch information
codex-spec committed Aug 15, 2021
commit 0eaaf6f96641dd1df951a30d98d82d21489bf5e7
13 changes: 7 additions & 6 deletions app/location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,36 @@
from ..coordinates import Coordinates
from ..utils import countries
from ..utils.populations import country_population
from creationalBP import DataLocation


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

@property
def country_code(self):
def country_code(DataLocation):
"""
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 (countries.country_code(super().__init__.country) or countries.DEFAULT_COUNTRY_CODE).upper()

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

:returns: The population.
:rtype: int
"""
return country_population(self.country_code)
return country_population(super().__init__.country_code)

class TimelinedLocation(Location):
class TimelinedLocation(DataLocation):
"""
A location with timelines.
"""
Expand Down
9 changes: 4 additions & 5 deletions app/location/csbs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""app.locations.csbs.py"""
from . import Location
from . import DataLocation


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

# pylint: disable=too-many-arguments,redefined-builtin
Expand All @@ -28,7 +28,6 @@ def __init__(self, id, state, county, coordinates, last_updated, confirmed, deat
def serialize(self, timelines=False): # pylint: disable=arguments-differ,unused-argument
"""
Serializes the location into a dict.

:returns: The serialized location.
:rtype: dict
"""
Expand All @@ -40,4 +39,4 @@ def serialize(self, timelines=False): # pylint: disable=arguments-differ,unused
)

# Return the serialized location.
return serialized
return serialized