[issue10499] Modular interpolation in configparser

2010-11-23 Thread Alexander Solovyov

Changes by Alexander Solovyov :


--
nosy: +asolovyov

___
Python tracker 
<http://bugs.python.org/issue10499>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9876] ConfigParser can't interpolate values from other sections

2010-09-16 Thread Alexander Solovyov

New submission from Alexander Solovyov :

Often it is useful to access some variable in other section for interpolation 
needs: for example, parent directory declared in common section could be used 
in configuration of certain components. Included patch can fix that (using 
syntax 'section.variable'), is there any chances that it could be applied? :)


--- ConfigParser.old.py 2010-09-16 19:20:27.0 +0300
+++ ConfigParser.py 2010-09-16 19:22:33.0 +0300
@@ -585,7 +585,7 @@
 if "%(" in value:
 value = self._KEYCRE.sub(self._interpolation_replace, value)
 try:
-value = value % vars
+value = value % _Context(self, section)
 except KeyError, e:
 raise InterpolationMissingOptionError(
 option, section, rawval, e.args[0])
@@ -667,3 +667,15 @@
 raise ValueError("invalid interpolation syntax in %r at "
  "position %d" % (value, m.start()))
 ConfigParser.set(self, section, option, value)
+
+
+class _Context(object):
+def __init__(self, config, section):
+self.config = config
+self.section = section
+
+def __getitem__(self, key):
+if '.' in key:
+return self.config.get(*key.split('.'))
+else:
+return self.config.get(self.section, key)

--
components: Library (Lib)
messages: 116573
nosy: asolovyov
priority: normal
severity: normal
status: open
title: ConfigParser can't interpolate values from other sections
type: feature request
versions: Python 2.7

___
Python tracker 
<http://bugs.python.org/issue9876>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1424152] urllib/urllib2: HTTPS over (Squid) Proxy fails

2009-05-16 Thread Alexander Solovyov

Changes by Alexander Solovyov :


--
nosy: +piranha

___
Python tracker 
<http://bugs.python.org/issue1424152>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com