使用自定义路径加载配置文件
(cls, file_path)
| 78 | |
| 79 | @classmethod |
| 80 | def custome_config(cls, file_path): |
| 81 | """使用自定义路径加载配置文件""" |
| 82 | custom_path = Path(file_path) |
| 83 | if not custom_path.exists(): |
| 84 | raise ValueError(f"Config file {custom_path} not found!") |
| 85 | # 加锁 |
| 86 | with cls._lock: |
| 87 | instance = cls() |
| 88 | instance._config_path = custom_path |
| 89 | # 此处传 isInit=False,若不存在则报错;若存在则正常 _load_config() |
| 90 | instance._ensure_config_exists(isInit=False) |
| 91 | cls._instance = instance |
| 92 | |
| 93 | @classmethod |
| 94 | def get(cls, key, default=None): |
no test coverage detected