INNER CODE UNIT · Python
find_existing_config_files
ImranR98/apps.obtainium.imranr.dev · scripts/generate_from_url.py:107
def find_existing_config_files(app_id):
"""Find existing config files for an app id in either folder."""
return [
os.path.join(APPS_PATH, folder, f"{app_id}.json")
for folder in ("complex", "simple")
if os.path.exists(os.path.join(APPS_PATH, folder, f"{app_id}.json"))
]
def find_config_file(name):
"""Locate a config file by file name or path relative to the apps folder."""
candidate = os.path.abspath(os.path.join(APPS_PATH, name))
if os.path.commonpath([APPS_PATH, candidate]) != APPS_PATH:
print(Fore.RED + "The file name must stay inside public/data/apps.")
return None
if "/" in name or os.path.sep in name:
return candidate if os.path.exists(candidate) else None
for folder in ("complex", "simple"):