summaryrefslogtreecommitdiff
path: root/configobj.py
diff options
context:
space:
mode:
authorfuzzyman <devnull@localhost>2010-02-27 19:05:24 +0000
committerfuzzyman <devnull@localhost>2010-02-27 19:05:24 +0000
commit045d26e83cafc87e1da5d7960f1cadc88696b20e (patch)
tree3a10d481942a7f2323457120d7635eb7da15eb36 /configobj.py
parentb5bc74d538a40a1dfecf3dcb6e35c17b747d36f5 (diff)
downloadconfigobj-045d26e83cafc87e1da5d7960f1cadc88696b20e.tar.gz
Values refering missing interpolation options can now be repr'd. Issue 9.
Diffstat (limited to 'configobj.py')
-rw-r--r--configobj.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/configobj.py b/configobj.py
index 3827cee..7e3adee 100644
--- a/configobj.py
+++ b/configobj.py
@@ -753,7 +753,12 @@ class Section(dict):
def __repr__(self):
"""x.__repr__() <==> repr(x)"""
- return '{%s}' % ', '.join([('%s: %s' % (repr(key), repr(self[key])))
+ def _getval(key):
+ try:
+ return self[key]
+ except MissingInterpolationOption:
+ return dict.__getitem__(self, key)
+ return '{%s}' % ', '.join([('%s: %s' % (repr(key), repr(_getval(key))))
for key in (self.scalars + self.sections)])
__str__ = __repr__
@@ -1367,8 +1372,13 @@ class ConfigObj(Section):
def __repr__(self):
+ def _getval(key):
+ try:
+ return self[key]
+ except MissingInterpolationOption:
+ return dict.__getitem__(self, key)
return ('ConfigObj({%s})' %
- ', '.join([('%s: %s' % (repr(key), repr(self[key])))
+ ', '.join([('%s: %s' % (repr(key), repr(_getval(key))))
for key in (self.scalars + self.sections)]))