Spaces:
Runtime error
Runtime error
Download src/modules/transporter/__init__.py from pnstack/template-python: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/pnstack/template-python/resolve/43909516e0cf3c8301074a335734d496399a54b9/src/modules/transporter/__init__.py
- Command line
-
hf download hf://spaces/pnstack/template-python@43909516e0cf3c8301074a335734d496399a54b9/src/modules/transporter/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/pnstack/template-python/resolve/43909516e0cf3c8301074a335734d496399a54b9/src/modules/transporter/__init__.py
966 Bytes
| # app/utils/__init__.py | |
| import os | |
| import importlib | |
| import pkgutil | |
| # Lấy tên package hiện tại | |
| __all__ = [] | |
| # Duyệt tất cả module con trong thư mục hiện tại (không đệ quy) | |
| package_dir = os.path.dirname(__file__) | |
| for _, module_name, is_pkg in pkgutil.iter_modules([package_dir]): | |
| if not is_pkg and module_name != "__init__": | |
| module = importlib.import_module(f".{module_name}", package=__name__) | |
| # Nếu module có biến __all__, import những gì nó khai báo | |
| if hasattr(module, "__all__"): | |
| for attr in module.__all__: | |
| globals()[attr] = getattr(module, attr) | |
| __all__.append(attr) | |
| else: | |
| # Import tất cả public attributes (không bắt đầu bằng _) | |
| for attr in dir(module): | |
| if not attr.startswith("_"): | |
| globals()[attr] = getattr(module, attr) | |
| __all__.append(attr) | |