Load Tortoise ORM configuration from various sources. Returns: TortoiseConfig: Validated configuration object
(ctx: CLIContext)
| 169 | |
| 170 | |
| 171 | def _load_config(ctx: CLIContext) -> TortoiseConfig: |
| 172 | """Load Tortoise ORM configuration from various sources. |
| 173 | |
| 174 | Returns: |
| 175 | TortoiseConfig: Validated configuration object |
| 176 | """ |
| 177 | config_value = ctx.config |
| 178 | config_file = ctx.config_file |
| 179 | if config_file: |
| 180 | config_dict = Tortoise._get_config_from_config_file(config_file) |
| 181 | return TortoiseConfig.from_dict(config_dict) |
| 182 | if not config_value: |
| 183 | config_value = utils.tortoise_orm_config() |
| 184 | if not config_value: |
| 185 | raise utils.CLIUsageError( |
| 186 | "You must specify TORTOISE_ORM in option or env, or pyproject.toml [tool.tortoise]", |
| 187 | ) |
| 188 | return utils.get_tortoise_config(config_value) |
| 189 | |
| 190 | |
| 191 | def _select_apps(config: TortoiseConfig, app_labels: Iterable[str] | None) -> dict[str, AppConfig]: |
no test coverage detected
searching dependent graphs…