Not catch exception when import config. (#164)
This commit is contained in:
parent
9bf2de0b9a
commit
1dbf9185b6
@ -5,6 +5,7 @@
|
|||||||
### 0.5.4
|
### 0.5.4
|
||||||
|
|
||||||
- Fix incorrect index creation order. (#151)
|
- Fix incorrect index creation order. (#151)
|
||||||
|
- Not catch exception when import config. (#164)
|
||||||
|
|
||||||
### 0.5.3
|
### 0.5.3
|
||||||
|
|
||||||
|
@ -42,13 +42,7 @@ def get_tortoise_config(ctx: Context, tortoise_orm: str) -> dict:
|
|||||||
splits = tortoise_orm.split(".")
|
splits = tortoise_orm.split(".")
|
||||||
config_path = ".".join(splits[:-1])
|
config_path = ".".join(splits[:-1])
|
||||||
tortoise_config = splits[-1]
|
tortoise_config = splits[-1]
|
||||||
try:
|
|
||||||
config_module = importlib.import_module(config_path)
|
config_module = importlib.import_module(config_path)
|
||||||
except (ModuleNotFoundError, AttributeError):
|
|
||||||
raise BadOptionUsage(
|
|
||||||
ctx=ctx, message=f'No config named "{config_path}"', option_name="--config"
|
|
||||||
)
|
|
||||||
|
|
||||||
config = getattr(config_module, tortoise_config, None)
|
config = getattr(config_module, tortoise_config, None)
|
||||||
if not config:
|
if not config:
|
||||||
raise BadOptionUsage(
|
raise BadOptionUsage(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user