refactor: improve component loading logic and add resource directory check

This commit is contained in:
RockChinQ
2026-03-23 01:39:14 +08:00
committed by huanghuoguoguo
parent 0923da6ead
commit 116634ebdf
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