-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
61 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
from trakt.core.abstract.abstract_api import AbstractApi | ||
from trakt.core.abstract.abstract_component import AbstractComponent | ||
from trakt.core.abstract.abstract_models import AbstractBaseModel | ||
from __future__ import annotations | ||
|
||
from typing import Any, Dict, Type, TypeVar, cast | ||
|
||
import jsons | ||
|
||
|
||
class AbstractApi: | ||
pass | ||
|
||
|
||
class AbstractComponent: | ||
name: str = "base_component" | ||
client: AbstractApi | ||
|
||
def __init__(self, client: AbstractApi) -> None: | ||
self.client = client | ||
|
||
|
||
class _AbstractFromJson: | ||
pass | ||
|
||
|
||
T = TypeVar("T", bound=_AbstractFromJson) | ||
|
||
|
||
class AbstractBaseModel(_AbstractFromJson): | ||
_client = AbstractApi() | ||
|
||
@classmethod | ||
def from_json(cls: Type[T], data: Dict[str, Any]) -> T: | ||
obj = jsons.load(data, cls) | ||
return cast(T, obj) | ||
|
||
@classmethod | ||
def set_client(cls, client: AbstractApi) -> None: | ||
cls._client = client | ||
|
||
@property | ||
def client(self) -> AbstractApi: | ||
return self._client |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
from typing import List | ||
|
||
from trakt.core.abstract import AbstractApi | ||
from trakt.core.restpaths import Path | ||
|
||
|
||
class Executor: | ||
params: List[str] | ||
client: AbstractApi | ||
paths: List[Path] | ||
|
||
def __init__(self, client, module): | ||
def __init__(self, client: AbstractApi, module: str) -> None: | ||
self.params = [module] | ||
self.client = client | ||
self.paths = [] | ||
|
||
def __getattr__(self, param): | ||
def __getattr__(self, param: str) -> "Executor": | ||
self.params.append(param) | ||
|
||
return self | ||
|
||
def __repr__(self) -> str: | ||
return f'Executor(params={".".join(self.params)})' | ||
|
||
def __call__(self, *args, **kwargs): | ||
return repr(self) | ||
|
||
def __repr__(self): | ||
return f'Executor(params={".".join(self.params)})' | ||
def install(self, paths): | ||
if isinstance(paths, list): | ||
self.paths.extend(paths) | ||
else: | ||
self.paths.append(paths) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters