From 2e4e485ed00e2e9a5a28cf9165702b04d5ee674e Mon Sep 17 00:00:00 2001 From: drupman Date: Thu, 9 Nov 2023 13:52:42 -0300 Subject: [PATCH] (feat) add get databases function --- utils/os_utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/utils/os_utils.py b/utils/os_utils.py index c5cd6e2..5310e42 100644 --- a/utils/os_utils.py +++ b/utils/os_utils.py @@ -121,6 +121,21 @@ def get_bots_data_paths(): return data_sources +def get_databases(): + databases = {} + bots_data_paths = get_bots_data_paths() + for source_name, source_path in bots_data_paths.items(): + sqlite_files = {} + for db_name in os.listdir(source_path): + if db_name.endswith(".sqlite"): + sqlite_files[db_name] = os.path.join(source_path, db_name) + databases[source_name] = sqlite_files + if len(databases) > 0: + return {key: value for key, value in databases.items() if value} + else: + return None + + def get_function_from_file(file_path: str, function_name: str): # Create a module specification from the file path and load it spec = importlib.util.spec_from_file_location("module.name", file_path)