Source code for swdata

"""
This a public API for the swdata package.

Everything beside classes declared in this module should be considered private
and subject to change without notice. This is an architectural decision to
give this module an autonomy over it's design and implementation.

ATM we are using poor man's dependency injection delivered by dataclass fields.
Preferably we should use a proper Inversion Of Control container engine that
would give use the flexibility of defining a default types and setup mappings
like the one between PlanetProvider abstract class and a concrete
implementation of EagerPlanetProvider — mappings like this should come from
the container setup not class declarations.

ATM the control over injected instances is delegated to the field declarations
and setup by default_factory.

"""

from dataclasses import dataclass, field

from swdata.people import PeopleSaver
from swdata.reports import Report, ReportViewer

__all__ = ['SWPeople']


[docs]@dataclass class SWPeople: """Gateway class for reporting functionality over SW People data.""" _saver: PeopleSaver = field(default_factory=PeopleSaver)
[docs] def create_collection(self, directory='reports') -> Report: return self._saver.save(directory=directory)
[docs] @staticmethod def get_people_data(path, start=0, stop=10): return ReportViewer(path=path)[start:stop]
[docs] @staticmethod def get_distinct(path, *columns): return ReportViewer(path=path).distinct(*columns)