diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-01-27 07:32:38 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-01-27 07:33:14 -0500 |
commit | a559e7cc2cd4de6095aa84347e36a7c526cd6147 (patch) | |
tree | 53912aa7a2499c4e178bd367f26425a7777ecb41 /coverage/config.py | |
parent | c25660176f90b466abd403a50a03962bcb5e913a (diff) | |
download | python-coveragepy-git-a559e7cc2cd4de6095aa84347e36a7c526cd6147.tar.gz |
refactor: Move post-processing into CoverageConfig
Diffstat (limited to 'coverage/config.py')
-rw-r--r-- | coverage/config.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/coverage/config.py b/coverage/config.py index 803dcd5d..026f8645 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -477,6 +477,20 @@ class CoverageConfig(object): # If we get here, we didn't find the option. raise CoverageException("No such option: %r" % option_name) + def post_process_file(self, path): + """Make final adjustments to a file path to make it usable.""" + return os.path.expanduser(path) + + def post_process(self): + """Make final adjustments to settings to make them usable.""" + self.data_file = self.post_process_file(self.data_file) + self.html_dir = self.post_process_file(self.html_dir) + self.xml_output = self.post_process_file(self.xml_output) + self.paths = collections.OrderedDict( + (k, [self.post_process_file(f) for f in v]) + for k, v in self.paths.items() + ) + def config_files_to_try(config_file): """What config files should we try to read? @@ -551,12 +565,6 @@ def read_coverage_config(config_file, **kwargs): # Once all the config has been collected, there's a little post-processing # to do. - config.data_file = os.path.expanduser(config.data_file) - config.html_dir = os.path.expanduser(config.html_dir) - config.xml_output = os.path.expanduser(config.xml_output) - config.paths = collections.OrderedDict( - (k, [os.path.expanduser(f) for f in v]) - for k, v in config.paths.items() - ) + config.post_process() return config |