summaryrefslogtreecommitdiff
path: root/coverage/config.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-08-02 12:51:14 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-08-02 12:51:14 -0400
commit532ca16b158b8e8ffb8857237a801ec7e641bf46 (patch)
tree0cfbeedffe34378a1f5149a0bf05362dc8b3739b /coverage/config.py
parent959447537d8d8f4d91f5bf25b810e49bdaffddf6 (diff)
downloadpython-coveragepy-git-532ca16b158b8e8ffb8857237a801ec7e641bf46.tar.gz
Change the coverage.config item-access syntax to a real method call.
The square brackets were too cute, and I couldn't figure out how to document them anyway!
Diffstat (limited to 'coverage/config.py')
-rw-r--r--coverage/config.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/coverage/config.py b/coverage/config.py
index 9939d6c0..83eea519 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -310,8 +310,17 @@ class CoverageConfig(object):
"""Get a dictionary of options for the plugin named `plugin`."""
return self.plugin_options.get(plugin, {})
- # TODO: docs for this.
- def __setitem__(self, option_name, value):
+ def set_option(self, option_name, value):
+ """Set an option in the configuration.
+
+ `option_name` is a colon-separated string indicating the section and
+ option name. For example, the ``branch`` option in the ``[run]``
+ section of the config file would be indicated with `"run:branch"`.
+
+ `value` is the new value for the option.
+
+ """
+
# Check all the hard-coded options.
for option_spec in self.CONFIG_FILE_OPTIONS:
attr, where = option_spec[:2]
@@ -328,8 +337,17 @@ class CoverageConfig(object):
# 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, option_name):
+ def get_option(self, option_name):
+ """Get an option from the configuration.
+
+ `option_name` is a colon-separated string indicating the section and
+ option name. For example, the ``branch`` option in the ``[run]``
+ section of the config file would be indicated with `"run:branch"`.
+
+ Returns the value of the option.
+
+ """
+
# Check all the hard-coded options.
for option_spec in self.CONFIG_FILE_OPTIONS:
attr, where = option_spec[:2]