Improved app_config.get_config_value - added ability to get hierarchical YAML configs

This commit is contained in:
Anry Das 2025-10-11 16:54:58 +03:00
parent d2df6a005b
commit 202a3eb383
2 changed files with 8 additions and 2 deletions

View File

@ -31,7 +31,13 @@ def read_app_config():
return j return j
def get_config_value(cfg, section, key, default): def get_config_value(cfg, section, key, default):
return cfg[section][key] if section in cfg and key in cfg[section] else default if '.' in section:
s = section.split('.', 1)
new_section = s[1]
new_cfg = cfg[s[0]]
return get_config_value(new_cfg, new_section, key, default)
else:
return cfg[section][key] if section in cfg and key in cfg[section] else default
def parse_config(cfg): def parse_config(cfg):
global UPLOAD_DIR, APP_PORT, IS_DEBUG, DB_URL, ALIAS_NUM_LETTERS, ALIAS_NUM_DIGITS\ global UPLOAD_DIR, APP_PORT, IS_DEBUG, DB_URL, ALIAS_NUM_LETTERS, ALIAS_NUM_DIGITS\

View File

@ -385,7 +385,7 @@ async def download_file(
async def download_link( async def download_link(
file_id: str file_id: str
): ):
"""Download a file by LINK (without API key)""" """Download a file by DIRECT LINK (without API key)"""
async with db_pool.acquire() as conn: async with db_pool.acquire() as conn:
# Get file info and verify ownership # Get file info and verify ownership
file_info = await conn.fetchrow(""" file_info = await conn.fetchrow("""