refactor: improve component loading logic and add resource directory check

This commit is contained in:
RockChinQ
2026-07-19 22:38:10 +08:00
committed by huanghuoguoguo
parent 45679a4629
commit 1d40c9b995
4 changed files with 16 additions and 5 deletions
+7
View File
@@ -47,3 +47,10 @@ def read_resource_file_bytes(resource_path: str) -> bytes:
def list_resource_files(resource_path: str) -> list[str]:
return [f.name for f in importlib.resources.files('langbot').joinpath(resource_path).iterdir()]
def is_resource_dir(resource_path: str) -> bool:
try:
return importlib.resources.files('langbot').joinpath(resource_path).is_dir()
except (TypeError, FileNotFoundError):
return False