Created
March 8, 2019 02:14
-
-
Save tszumowski/51b28a6e69598c934b0cf809ae9a82c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get(self, section, key, **kwargs): | |
section = str(section).lower() | |
key = str(key).lower() | |
deprecated_name = self.deprecated_options.get(section, {}).get(key, None) | |
# first check environment variables | |
option = self._get_env_var_option(section, key) | |
if option is not None: | |
return option | |
if deprecated_name: | |
option = self._get_env_var_option(section, deprecated_name) | |
if option is not None: | |
self._warn_deprecate(section, key, deprecated_name) | |
return option | |
# ...then the config file | |
if super(AirflowConfigParser, self).has_option(section, key): | |
# Use the parent's methods to get the actual config here to be able to | |
# separate the config from default config. | |
return expand_env_var( | |
super(AirflowConfigParser, self).get(section, key, **kwargs)) | |
if deprecated_name: | |
if super(AirflowConfigParser, self).has_option(section, deprecated_name): | |
self._warn_deprecate(section, key, deprecated_name) | |
return expand_env_var(super(AirflowConfigParser, self).get( | |
section, | |
deprecated_name, | |
**kwargs | |
)) | |
# ...then commands | |
option = self._get_cmd_option(section, key) | |
if option: | |
return option | |
if deprecated_name: | |
option = self._get_cmd_option(section, deprecated_name) | |
if option: | |
self._warn_deprecate(section, key, deprecated_name) | |
return option | |
# ...then the default config | |
if self.airflow_defaults.has_option(section, key) or 'fallback' in kwargs: | |
return expand_env_var( | |
self.airflow_defaults.get(section, key, **kwargs)) | |
else: | |
log.warning( | |
"section/key [{section}/{key}] not found in config".format(**locals()) | |
) | |
raise AirflowConfigException( | |
"section/key [{section}/{key}] not found " | |
"in config".format(**locals())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment