2023-12-01 00:12:16 +00:00
|
|
|
from app.repo import AnsiColor, Repo
|
|
|
|
from typing import Union
|
|
|
|
from typing_extensions import TypedDict
|
|
|
|
|
|
|
|
|
|
|
|
class Export(TypedDict, total=False):
|
2023-12-01 03:35:20 +00:00
|
|
|
# The coach's rapid rating as listed on the site they were sourced from.
|
|
|
|
rapid: int
|
2023-12-01 00:12:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BaseExporter(Repo):
|
|
|
|
def __init__(self, site: str, username: str):
|
|
|
|
super().__init__(site)
|
|
|
|
self.username = username
|
|
|
|
|
2023-12-01 03:35:20 +00:00
|
|
|
def export_rapid(self) -> Union[int, None]:
|
2023-12-01 00:12:16 +00:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
def export(self) -> Export:
|
|
|
|
"""Transform coach-specific data into uniform format."""
|
|
|
|
export: Export = {}
|
|
|
|
|
2023-12-01 03:35:20 +00:00
|
|
|
rapid = self.export_rapid()
|
|
|
|
if rapid:
|
|
|
|
export["rapid"] = rapid
|
2023-12-01 00:12:16 +00:00
|
|
|
|
|
|
|
self.log(
|
|
|
|
[
|
|
|
|
(AnsiColor.INFO, "[INFO]"),
|
|
|
|
(None, ": Exported "),
|
|
|
|
(AnsiColor.DATA, self.username),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
return export
|