comparison 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
comparison
equal deleted inserted replaced
4068:5b1f663ef86d 4069:3fef134832d8
114 ) 114 )
115 115
116 class SignalInterrupt(Exception): 116 class SignalInterrupt(Exception):
117 """Exception raised on SIGTERM and SIGHUP.""" 117 """Exception raised on SIGTERM and SIGHUP."""
118 118
119 # like SafeConfigParser but with case-sensitive keys 119 # differences from SafeConfigParser:
120 # - case-sensitive keys
121 # - allows values that are not strings (this means that you may not
122 # be able to save the configuration to a file)
120 class configparser(ConfigParser.SafeConfigParser): 123 class configparser(ConfigParser.SafeConfigParser):
121 def optionxform(self, optionstr): 124 def optionxform(self, optionstr):
122 return optionstr 125 return optionstr
126
127 def set(self, section, option, value):
128 return ConfigParser.ConfigParser.set(self, section, option, value)
129
130 def _interpolate(self, section, option, rawval, vars):
131 if not isinstance(rawval, basestring):
132 return rawval
133 return ConfigParser.SafeConfigParser._interpolate(self, section,
134 option, rawval, vars)
123 135
124 def cachefunc(func): 136 def cachefunc(func):
125 '''cache the result of function calls''' 137 '''cache the result of function calls'''
126 # XXX doesn't handle keywords args 138 # XXX doesn't handle keywords args
127 cache = {} 139 cache = {}