Added ability to get raw configuration parameter values
This commit is contained in:
parent
4ceec12865
commit
cc79d5896c
@ -77,7 +77,7 @@ class Configuration(object):
|
||||
|
||||
return '%s.%s' % (section, param)
|
||||
|
||||
def get(self, name, default=None, _state=[]):
|
||||
def get(self, name, default=None, raw=False, _state=[]):
|
||||
section, name = self._normalize_name(name)
|
||||
|
||||
if section in self._normal and name in self._normal[section]:
|
||||
@ -90,6 +90,9 @@ class Configuration(object):
|
||||
if not isinstance(value, str):
|
||||
return value
|
||||
|
||||
if raw:
|
||||
return value
|
||||
|
||||
tmpl = string.Template(value)
|
||||
return tmpl.safe_substitute(ConfigurationWrapper(self, _state + [name]))
|
||||
|
||||
|
@ -195,3 +195,11 @@ class ConfigurationTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual('cba', c.get('c'))
|
||||
|
||||
def test_getting_raw_values(self):
|
||||
c = Configuration()
|
||||
|
||||
c.set('a', '$b')
|
||||
c.set('b', 'x')
|
||||
|
||||
self.assertEqual('$b', c.get('a', raw=True))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user