Feat: add __init__ and mod function signature

This commit is contained in:
Bertrand Benjamin 2024-08-14 07:21:36 +02:00
parent 2de0e5ef5c
commit 91e229eab2
6 changed files with 14 additions and 48 deletions

View File

View File

@ -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

View File

@ -55,7 +55,7 @@ class FSRepository(AbstractRepository):
raise ValueError("Can't open the table") 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) table_path = self.build_table_path(table, schema)
pass pass

View File

@ -1,4 +1,5 @@
import abc import abc
from .metadata import AbstractMetadataEngine from .metadata import AbstractMetadataEngine
@ -6,31 +7,31 @@ class AbstractRepository(abc.ABC):
metadata_engine = AbstractMetadataEngine metadata_engine = AbstractMetadataEngine
@abc.abstractmethod @abc.abstractmethod
def schemas(): def schemas(self) -> list[str]:
""" List schemas """ """List schemas"""
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def tables(schema): def tables(self, schema) -> list[str]:
""" List table in schema""" """List table in schema"""
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def info(self, path): def infos(self, table: str, schema: str) -> dict[str, str]:
""" Get infos about a file""" """Get infos about the table"""
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def read(self, path): def read(self, table: str, schema: str):
""" Get content of a file""" """Get content of the table"""
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def write(self, path, content): def write(self, content, table: str, schema: str):
""" Write content into the file""" """Write content into the table"""
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
def delete(self, path): def delete_table(self, table: str, schema: str):
""" Delete the file """ """Delete the table"""
raise NotImplementedError raise NotImplementedError

0
tests/__init__.py Normal file
View File