From 91e229eab2930d4af0a275e8b5c533aeb37e5d09 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 14 Aug 2024 07:21:36 +0200 Subject: [PATCH] Feat: add __init__ and mod function signature --- tests/__ini__.py => dashboard/__init__.py | 0 dashboard/libs/flux/__init__.py | 0 dashboard/libs/fs_schema.py | 35 ---------------------- dashboard/libs/repository/fs_repository.py | 2 +- dashboard/libs/repository/repository.py | 25 ++++++++-------- tests/__init__.py | 0 6 files changed, 14 insertions(+), 48 deletions(-) rename tests/__ini__.py => dashboard/__init__.py (100%) create mode 100644 dashboard/libs/flux/__init__.py delete mode 100644 dashboard/libs/fs_schema.py create mode 100644 tests/__init__.py diff --git a/tests/__ini__.py b/dashboard/__init__.py similarity index 100% rename from tests/__ini__.py rename to dashboard/__init__.py diff --git a/dashboard/libs/flux/__init__.py b/dashboard/libs/flux/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dashboard/libs/fs_schema.py b/dashboard/libs/fs_schema.py deleted file mode 100644 index 4836858..0000000 --- a/dashboard/libs/fs_schema.py +++ /dev/null @@ -1,35 +0,0 @@ -from .schema import AbstractSchema -from pathlib import Path - -class FSSchema(AbstractSchema): - def __init__(self, basepath, metadata_engine=None): - self.basepath = basepath - self._metadata_engine = metadata_engine - - def ls(self, dir, only_files=True): - dirpath = Path(dir) - if only_files: - return [f for f in dirpath.iterdir() if f.is_dir()] - return [f for f in dirpath.iterdir()] - - def tables(self, dir, only_files=True): - dirpath = Path(dir) - if only_files: - return [f for f in dirpath.iterdir() if f.is_dir()] - return [f for f in dirpath.iterdir()] - - def info(self, path): - path = Path(path) - pass - - def read(self, path): - path = Path(path) - pass - - def write(self, path, content): - path = Path(path) - pass - - def delete(self, path): - path = Path(path) - pass diff --git a/dashboard/libs/repository/fs_repository.py b/dashboard/libs/repository/fs_repository.py index 3c4eee8..c74ac51 100644 --- a/dashboard/libs/repository/fs_repository.py +++ b/dashboard/libs/repository/fs_repository.py @@ -55,7 +55,7 @@ class FSRepository(AbstractRepository): raise ValueError("Can't open the table") - def write(self, table:str, content, schema:str='.'): + def write(self, content, table:str, schema:str='.'): table_path = self.build_table_path(table, schema) pass diff --git a/dashboard/libs/repository/repository.py b/dashboard/libs/repository/repository.py index 3605de7..031e510 100644 --- a/dashboard/libs/repository/repository.py +++ b/dashboard/libs/repository/repository.py @@ -1,4 +1,5 @@ import abc + from .metadata import AbstractMetadataEngine @@ -6,31 +7,31 @@ class AbstractRepository(abc.ABC): metadata_engine = AbstractMetadataEngine @abc.abstractmethod - def schemas(): - """ List schemas """ + def schemas(self) -> list[str]: + """List schemas""" raise NotImplementedError @abc.abstractmethod - def tables(schema): - """ List table in schema""" + def tables(self, schema) -> list[str]: + """List table in schema""" raise NotImplementedError @abc.abstractmethod - def info(self, path): - """ Get infos about a file""" + def infos(self, table: str, schema: str) -> dict[str, str]: + """Get infos about the table""" raise NotImplementedError @abc.abstractmethod - def read(self, path): - """ Get content of a file""" + def read(self, table: str, schema: str): + """Get content of the table""" raise NotImplementedError @abc.abstractmethod - def write(self, path, content): - """ Write content into the file""" + def write(self, content, table: str, schema: str): + """Write content into the table""" raise NotImplementedError @abc.abstractmethod - def delete(self, path): - """ Delete the file """ + def delete_table(self, table: str, schema: str): + """Delete the table""" raise NotImplementedError diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29