| Total Complexity | 5 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | from typing import Type |
||
| 10 | class Application: |
||
| 11 | def __init__(self, settings: Type[AbstractSettings], routes: list) -> None: |
||
| 12 | self._settings = settings |
||
| 13 | self._initialize_settings(routes) |
||
| 14 | |||
| 15 | def _initialize_settings(self, routes: list): |
||
| 16 | self._settings.init_resource('schema', routes=routes) |
||
| 17 | self._settings.init_resource('router', schema=self._settings.schema) |
||
| 18 | self._settings.init_resource('runner', router=self._settings.router) |
||
| 19 | |||
| 20 | mountapi.core.settings = self._settings |
||
| 21 | |||
| 22 | if isinstance(self._settings.schema, AbstractSchema): |
||
| 23 | self._settings.schema.build() |
||
| 24 | |||
| 25 | def run(self) -> None: |
||
| 26 | if isinstance(self._settings.runner, AbstractRunner): |
||
| 27 | self._settings.runner.run(self._settings) |
||
| 28 | else: |
||
| 29 | raise InvalidRunner() |
||
| 30 |