Load config files by environment.
(self)
| 975 | |
| 976 | @catch_config_error |
| 977 | def load_config_environ(self) -> None: |
| 978 | """Load config files by environment.""" |
| 979 | PREFIX = self.name.upper().replace("-", "_") |
| 980 | new_config = Config() |
| 981 | |
| 982 | self.log.debug('Looping through config variables with prefix "%s"', PREFIX) |
| 983 | |
| 984 | for k, v in os.environ.items(): |
| 985 | if k.startswith(PREFIX): |
| 986 | self.log.debug('Seeing environ "%s"="%s"', k, v) |
| 987 | # use __ instead of . as separator in env variable. |
| 988 | # Warning, case sensitive ! |
| 989 | _, *path, key = k.split("__") |
| 990 | section = new_config |
| 991 | for p in path: |
| 992 | section = section[p] |
| 993 | setattr(section, key, DeferredConfigString(v)) |
| 994 | |
| 995 | new_config.merge(self.cli_config) |
| 996 | self.update_config(new_config) |
| 997 | |
| 998 | def _classes_with_config_traits( |
| 999 | self, classes: ClassesType | None = None |
no test coverage detected