Skip to content
Open
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
36 changes: 0 additions & 36 deletions CONTRIBUTING.md

This file was deleted.

529 changes: 0 additions & 529 deletions README.md

This file was deleted.

49 changes: 33 additions & 16 deletions app/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
"""app.data"""
from ..services.location.csbs import CSBSLocationService
from ..services.location.jhu import JhuLocationService
from ..services.location.nyt import NYTLocationService
from ..services.location.csbs import CSBSLocationServicee
from ..services.location.jhu import JhuLocationServicee
from ..services.location.nyt import NYTLocationServicee
from app.services.location.__init__ import LocationServicer

# Mapping of services to data-sources.
DATA_SOURCES = {
"jhu": JhuLocationService(),
"csbs": CSBSLocationService(),
"nyt": NYTLocationService(),
}
class DataSourceSingletonMeta(type):
"""
access point to the DataSource
"""

_instances = {}

def data_source(source):
"""
Retrieves the provided data-source service.
def __call__(cls, *args, **kwargs):
"""
Possible changes to the value of the `__init__` argument do not affect
the returned instance.
"""
if cls not in cls._instances:
instance = super().__call__(*args, **kwargs)
cls._instances[cls] = instance
return cls._instances[cls]

:returns: The service.
:rtype: LocationService
"""
return DATA_SOURCES.get(source.lower())

class DataSourceSingleton(metaclass=DataSourceSingletonMeta):
DATA_SOURCES = {
"jhu": LocationServicer(JhuLocationServicee()),
"csbs": LocationServicer(CSBSLocationServicee()),
"nyt": LocationServicer(NYTLocationServicee()),
}
def get_data_source(self, dataSource):
return self.DATA_SOURCES.get(dataSource.lower())
...

def get_data_source_list(self):
return self.DATA_SOURCES


121 changes: 0 additions & 121 deletions app/main.py

This file was deleted.

110 changes: 0 additions & 110 deletions app/routers/v2.py

This file was deleted.

45 changes: 26 additions & 19 deletions app/services/location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,34 @@
from abc import ABC, abstractmethod


class LocationService(ABC):
class LocationServicer: # The 'Remote' of the Pattern
"""
Service for retrieving locations.
Abstraction class handling the 'Front End' portion of the project
"""

@abstractmethod
async def get_all(self):
"""
Gets and returns all of the locations.
def __init__(self, implementation):
self.implementation = implementation

@abstractmethod
def all_locations(self):
return self.implementation.get_all()

@abstractmethod
def locations(self):
return self.implementation.get()

class LocationServicee: # The 'Device' with the implmentation
"""
Implementation Interface
"""

def get_all(self):
# No implementation - interface method
pass

def get(self):
# No implementation - interface method
pass


:returns: The locations.
:rtype: List[Location]
"""
raise NotImplementedError

@abstractmethod
async def get(self, id): # pylint: disable=redefined-builtin,invalid-name
"""
Gets and returns location with the provided id.

:returns: The location.
:rtype: Location
"""
raise NotImplementedError
Loading