diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-11-03 10:17:40 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-11-03 21:27:42 -0500 |
commit | 25311c6caabed2f13da991dae52352c3c896a3e9 (patch) | |
tree | 347736ed68e204502d110bea0a8192ed3a2ffc5e /coverage/tomlconfig.py | |
parent | a44e6e48abfdab8f5a7e457ae1e481005f7bdbe5 (diff) | |
download | python-coveragepy-git-25311c6caabed2f13da991dae52352c3c896a3e9.tar.gz |
Expand environment variables in any part of a TOML config
Diffstat (limited to 'coverage/tomlconfig.py')
-rw-r--r-- | coverage/tomlconfig.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/coverage/tomlconfig.py b/coverage/tomlconfig.py index b6499ec4..144b13ca 100644 --- a/coverage/tomlconfig.py +++ b/coverage/tomlconfig.py @@ -8,7 +8,7 @@ import os import re from coverage import env -from coverage.backward import configparser, path_types, string_class, toml +from coverage.backward import configparser, path_types, toml from coverage.misc import CoverageException, substitute_variables @@ -41,7 +41,9 @@ class TomlConfigParser: for filename in filenames: try: with io.open(filename, encoding='utf-8') as fp: - self._data.append(toml.load(fp)) + toml_data = fp.read() + toml_data = substitute_variables(toml_data, os.environ) + self._data.append(toml.loads(toml_data)) except IOError: continue except toml.TomlDecodeError as err: @@ -101,8 +103,6 @@ class TomlConfigParser: value = section[option] except KeyError: continue - if isinstance(value, string_class): - value = substitute_variables(value, os.environ) return value if not found_section: raise configparser.NoSectionError(section) @@ -124,9 +124,6 @@ class TomlConfigParser: 'Option {!r} in section {!r} is not a list: {!r}' .format(option, section, values) ) - for i, value in enumerate(values): - if isinstance(value, string_class): - values[i] = substitute_variables(value, os.environ) return values def getregexlist(self, section, option): |