2323
2424logger = logging .getLogger (__name__ )
2525
26+ SYSTEM_CONFIG_FILENAME = "system_config.json"
2627
2728CONFIG_FILE = os .path .join (
28- os .path .dirname (__file__ ), ".." , ".." , ".." , "config" , "system_config.json"
29+ os .path .dirname (__file__ ), ".." , ".." , ".." , "config" , SYSTEM_CONFIG_FILENAME
2930)
3031
3132config_router = APIRouter (prefix = "/config-editor/api" , tags = ["ConfigEditor" ])
3233
3334
3435def normalize_config_filename (name : str ) -> str :
35- # Always return a valid config filename
36- if name .endswith ("system_config.json" ):
36+ if name == "system_config" :
37+ return SYSTEM_CONFIG_FILENAME
38+ if name .endswith (SYSTEM_CONFIG_FILENAME ):
3739 return name
3840 if name .endswith (".json" ):
3941 return name
40- return f"{ name } _system_config.json "
42+ return f"{ name } _ { SYSTEM_CONFIG_FILENAME } "
4143
4244
4345@config_router .get ("/config/{name}" , response_class = JSONResponse )
@@ -55,9 +57,9 @@ async def get_config_by_name(name: str):
5557@config_router .get ("/configs" , response_class = JSONResponse )
5658async def list_configs ():
5759 config_dir = os .path .dirname (CONFIG_FILE )
58- files = [f for f in os .listdir (config_dir ) if f .endswith ("_system_config.json " )]
60+ files = [f for f in os .listdir (config_dir ) if f .endswith (f"_ { SYSTEM_CONFIG_FILENAME } " )]
5961 # Strip suffix for user display
60- display_names = [f .replace ("_system_config.json " , "" ) for f in files ]
62+ display_names = [f .replace (f"_ { SYSTEM_CONFIG_FILENAME } " , "" ) for f in files ]
6163 return display_names
6264
6365
0 commit comments