| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -360,7 +360,9 @@ def get_value(self, section, option, default = None): | |||
| 360 | 360 | try: | |
| 361 | 361 | valuestr = self.get(section, option) | |
| 362 | 362 | except Exception: | |
| 363 | - return default | ||
| 363 | + if default is not None: | ||
| 364 | + return default | ||
| 365 | + raise | ||
| 364 | 366 | ||
| 365 | 367 | types = ( long, float ) | |
| 366 | 368 | for numtype in types: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,7 @@ class _SectionConstraint(object): | |||
| 21 | 21 | It supports all ConfigParser methods that operate on an option | |
| 22 | 22 | """ | |
| 23 | 23 | __slots__ = ("_config", "_section_name") | |
| 24 | - _valid_attrs_ = ("get", "set", "getint", "getfloat", "getboolean", "has_option") | ||
| 24 | + _valid_attrs_ = ("get_value", "set_value", "get", "set", "getint", "getfloat", "getboolean", "has_option") | ||
| 25 | 25 | ||
| 26 | 26 | def __init__(self, config, section): | |
| 27 | 27 | self._config = config | |
@@ -32,10 +32,10 @@ def __getattr__(self, attr): | |||
| 32 | 32 | return lambda *args: self._call_config(attr, *args) | |
| 33 | 33 | return super(_SectionConstraint,self).__getattribute__(attr) | |
| 34 | 34 | ||
| 35 | - def _call_config(self, method, *args): | ||
| 35 | + def _call_config(self, method, *args, **kwargs): | ||
| 36 | 36 | """Call the configuration at the given method which must take a section name | |
| 37 | 37 | as first argument""" | |
| 38 | - return getattr(self._config, method)(self._section_name, *args) | ||
| 38 | + return getattr(self._config, method)(self._section_name, *args, **kwargs) | ||
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | 41 | class PushProgress(object): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ | |||
| 8 | 8 | from git import * | |
| 9 | 9 | import StringIO | |
| 10 | 10 | from copy import copy | |
| 11 | + from ConfigParser import NoSectionError | ||
| 11 | 12 | ||
| 12 | 13 | class TestBase(TestCase): | |
| 13 | 14 | ||
@@ -97,4 +98,7 @@ def test_base(self): | |||
| 97 | 98 | default = "my default value" | |
| 98 | 99 | assert r_config.get_value("doesnt", "exist", default) == default | |
| 99 | 100 | ||
| 101 | + # it raises if there is no default though | ||
| 102 | + self.failUnlessRaises(NoSectionError, r_config.get_value, "doesnt", "exist") | ||
| 103 | + | ||
| 100 | 104 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -358,6 +358,7 @@ def test_base(self, rw_repo, remote_repo): | |||
| 358 | 358 | val = getattr(remote, opt) | |
| 359 | 359 | reader = remote.config_reader | |
| 360 | 360 | assert reader.get(opt) == val | |
| 361 | + assert reader.get_value(opt, None) == val | ||
| 361 | 362 | ||
| 362 | 363 | # unable to write with a reader | |
| 363 | 364 | self.failUnlessRaises(IOError, reader.set, opt, "test") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments