summaryrefslogtreecommitdiff
path: root/coverage/config.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-10-11 22:12:28 -0400
committerNed Batchelder <ned@nedbatchelder.com>2014-10-11 22:12:28 -0400
commit24b8bf63dc7d0fbf6abc3918892c3c2022342b45 (patch)
treefe8deeda84de81aa113b8c66ea2b01e7c58c0e55 /coverage/config.py
parent325906b1e80d65d400eaf4c6f928f662b6d114f8 (diff)
downloadpython-coveragepy-24b8bf63dc7d0fbf6abc3918892c3c2022342b45.tar.gz
Config tweaking applies to plugin options also
Diffstat (limited to 'coverage/config.py')
-rw-r--r--coverage/config.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/coverage/config.py b/coverage/config.py
index f262a04..4d599ee 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -2,6 +2,8 @@
import os, re, sys
from coverage.backward import string_class, iitems
+from coverage.misc import CoverageException
+
# In py3, # ConfigParser was renamed to the more-standard configparser
try:
@@ -268,16 +270,35 @@ class CoverageConfig(object):
return self.plugin_options.get(plugin, {})
# TODO: docs for this.
- def __setitem__(self, names, value):
+ def __setitem__(self, option_name, value):
+ # Check all the hard-coded options.
for option_spec in self.CONFIG_FILE_OPTIONS:
attr, where = option_spec[:2]
- if where == names:
+ if where == option_name:
setattr(self, attr, value)
return
+ # See if it's a plugin option.
+ plugin_name, _, key = option_name.partition(":")
+ if key and plugin_name in self.plugins:
+ self.plugin_options.setdefault(plugin_name, {})[key] = value
+ return
+
+ # If we get here, we didn't find the option.
+ raise CoverageException("No such option: %r" % option_name)
+
# TODO: docs for this.
- def __getitem__(self, names):
+ def __getitem__(self, option_name):
+ # Check all the hard-coded options.
for option_spec in self.CONFIG_FILE_OPTIONS:
attr, where = option_spec[:2]
- if where == names:
+ if where == option_name:
return getattr(self, attr)
+
+ # See if it's a plugin option.
+ plugin_name, _, key = option_name.partition(":")
+ if key and plugin_name in self.plugins:
+ return self.plugin_options.get(plugin_name, {}).get(key)
+
+ # If we get here, we didn't find the option.
+ raise CoverageException("No such option: %r" % option_name)