diff mercurial/util.py @ 4069:3fef134832d8

allow values that aren't strings in util.configparser
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 09 Feb 2007 03:48:26 -0200
parents 5b1f663ef86d
children 33c369afec94
line wrap: on
line diff
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -116,11 +116,23 @@ extendeddateformats = defaultdateformats
 class SignalInterrupt(Exception):
     """Exception raised on SIGTERM and SIGHUP."""
 
-# like SafeConfigParser but with case-sensitive keys
+# differences from SafeConfigParser:
+# - case-sensitive keys
+# - allows values that are not strings (this means that you may not
+#   be able to save the configuration to a file)
 class configparser(ConfigParser.SafeConfigParser):
     def optionxform(self, optionstr):
         return optionstr
 
+    def set(self, section, option, value):
+        return ConfigParser.ConfigParser.set(self, section, option, value)
+
+    def _interpolate(self, section, option, rawval, vars):
+        if not isinstance(rawval, basestring):
+            return rawval
+        return ConfigParser.SafeConfigParser._interpolate(self, section,
+                                                          option, rawval, vars)
+
 def cachefunc(func):
     '''cache the result of function calls'''
     # XXX doesn't handle keywords args