feat: add recursive schema
This commit is contained in:
parent
5b53630688
commit
29c82ae597
@ -6,20 +6,23 @@ class FSStage(AbstractStage):
|
|||||||
self.basepath = Path(basepath)
|
self.basepath = Path(basepath)
|
||||||
self._metadata_engine = metadata_engine
|
self._metadata_engine = metadata_engine
|
||||||
|
|
||||||
def ls(self, dir, only_files=False, only_directories=False) -> list[str]:
|
def ls(self, dir, only_files=False, only_directories=False, recursive=False) -> list[str]:
|
||||||
dirpath = Path(dir)
|
dirpath = Path(dir)
|
||||||
|
|
||||||
if only_files:
|
if only_files:
|
||||||
return [str(f.relative_to(dirpath)) for f in dirpath.iterdir() if not f.is_dir()]
|
return [str(f.relative_to(dirpath)) for f in dirpath.iterdir() if not f.is_dir()]
|
||||||
|
|
||||||
if only_directories:
|
if only_directories:
|
||||||
|
if recursive:
|
||||||
|
return [str(f[0].relative_to(dirpath)) for f in dirpath.walk()]
|
||||||
|
|
||||||
return [str(f.relative_to(dirpath)) for f in dirpath.iterdir() if f.is_dir()]
|
return [str(f.relative_to(dirpath)) for f in dirpath.iterdir() if f.is_dir()]
|
||||||
|
|
||||||
return [str(f.relative_to(dirpath)) for f in dirpath.iterdir()]
|
return [str(f.relative_to(dirpath)) for f in dirpath.iterdir()]
|
||||||
|
|
||||||
def schemas(self) -> list[str]:
|
def schemas(self, recursive=True) -> list[str]:
|
||||||
dirpath = self.basepath
|
dirpath = self.basepath
|
||||||
return self.ls(dirpath, only_directories=True)
|
return self.ls(dirpath, only_directories=True, recursive=True)
|
||||||
|
|
||||||
def tables(self, schema:str) -> list[str]:
|
def tables(self, schema:str) -> list[str]:
|
||||||
dirpath = self.basepath / schema
|
dirpath = self.basepath / schema
|
||||||
@ -27,22 +30,22 @@ class FSStage(AbstractStage):
|
|||||||
|
|
||||||
def build_table_path(self, table:str, schema:str):
|
def build_table_path(self, table:str, schema:str):
|
||||||
table_path = self.basepath
|
table_path = self.basepath
|
||||||
if schema == '':
|
if schema == '.':
|
||||||
return table_path / table
|
return table_path / table
|
||||||
return table_path / schema / table
|
return table_path / schema / table
|
||||||
|
|
||||||
def info(self, table:str, schema:str=''):
|
def info(self, table:str, schema:str='.'):
|
||||||
table_path = self.build_table_path(table, schema)
|
table_path = self.build_table_path(table, schema)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def read(self, table:str, schema:str=''):
|
def read(self, table:str, schema:str='.'):
|
||||||
table_path = self.build_table_path(table, schema)
|
table_path = self.build_table_path(table, schema)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def write(self, table:str, content, schema:str=''):
|
def write(self, table:str, content, schema:str='.'):
|
||||||
table_path = self.build_table_path(table, schema)
|
table_path = self.build_table_path(table, schema)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete(self, table:str, schema:str=''):
|
def delete(self, table:str, schema:str='.'):
|
||||||
table_path = self.build_table_path(table, schema)
|
table_path = self.build_table_path(table, schema)
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user