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")
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

View File

@ -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():
def schemas(self) -> list[str]:
"""List schemas"""
raise NotImplementedError
@abc.abstractmethod
def tables(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

0
tests/__init__.py Normal file
View File