diff --git a/dashboard/libs/stage/fs_stage.py b/dashboard/libs/stage/fs_stage.py index 6c89031..a957d02 100644 --- a/dashboard/libs/stage/fs_stage.py +++ b/dashboard/libs/stage/fs_stage.py @@ -6,20 +6,23 @@ class FSStage(AbstractStage): self.basepath = Path(basepath) 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) if only_files: return [str(f.relative_to(dirpath)) for f in dirpath.iterdir() if not f.is_dir()] 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()] - def schemas(self) -> list[str]: + def schemas(self, recursive=True) -> list[str]: 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]: dirpath = self.basepath / schema @@ -27,22 +30,22 @@ class FSStage(AbstractStage): def build_table_path(self, table:str, schema:str): table_path = self.basepath - if schema == '': + if schema == '.': return table_path / 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) pass - def read(self, table:str, schema:str=''): + def read(self, table:str, schema:str='.'): table_path = self.build_table_path(table, schema) 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) pass - def delete(self, table:str, schema:str=''): + def delete(self, table:str, schema:str='.'): table_path = self.build_table_path(table, schema) pass