This class loads config values from environment variables.
| 641 | |
| 642 | |
| 643 | class EnvironmentProvider(BaseProvider): |
| 644 | """This class loads config values from environment variables.""" |
| 645 | |
| 646 | def __init__(self, name, env): |
| 647 | """Initialize with the keys in the dictionary to check. |
| 648 | |
| 649 | :type name: str |
| 650 | :param name: The key with that name will be loaded and returned. |
| 651 | |
| 652 | :type env: dict |
| 653 | :param env: Environment variables dictionary to get variables from. |
| 654 | """ |
| 655 | self._name = name |
| 656 | self._env = env |
| 657 | |
| 658 | def provide(self): |
| 659 | """Provide a config value from a source dictionary.""" |
| 660 | if self._name in self._env: |
| 661 | return self._env[self._name] |
| 662 | return None |
| 663 | |
| 664 | def __repr__(self): |
| 665 | return f'EnvironmentProvider(name={self._name}, env={self._env})' |
| 666 | |
| 667 | |
| 668 | class SectionConfigProvider(BaseProvider): |
no outgoing calls