##// END OF EJS Templates
config: use the new '_unset' value for 'configwith'...
marmoute -
r32960:6ff6eb33 default
parent child Browse files
Show More
@@ -539,7 +539,7 b' class ui(object):'
539 % (section, name, v))
539 % (section, name, v))
540 return b
540 return b
541
541
542 def configwith(self, convert, section, name, default=None,
542 def configwith(self, convert, section, name, default=_unset,
543 desc=None, untrusted=False):
543 desc=None, untrusted=False):
544 """parse a configuration element with a conversion function
544 """parse a configuration element with a conversion function
545
545
@@ -551,7 +551,7 b' class ui(object):'
551 >>> u.configwith(float, s, 'float2')
551 >>> u.configwith(float, s, 'float2')
552 -4.25
552 -4.25
553 >>> u.configwith(float, s, 'unknown', 7)
553 >>> u.configwith(float, s, 'unknown', 7)
554 7
554 7.0
555 >>> u.setconfig(s, 'invalid', 'somevalue')
555 >>> u.setconfig(s, 'invalid', 'somevalue')
556 >>> u.configwith(float, s, 'invalid')
556 >>> u.configwith(float, s, 'invalid')
557 Traceback (most recent call last):
557 Traceback (most recent call last):
@@ -563,9 +563,9 b' class ui(object):'
563 ConfigError: foo.invalid is not a valid womble ('somevalue')
563 ConfigError: foo.invalid is not a valid womble ('somevalue')
564 """
564 """
565
565
566 v = self.config(section, name, None, untrusted)
566 v = self.config(section, name, default, untrusted)
567 if v is None:
567 if v is None:
568 return default
568 return v # do not attempt to convert None
569 try:
569 try:
570 return convert(v)
570 return convert(v)
571 except (ValueError, error.ParseError):
571 except (ValueError, error.ParseError):
General Comments 0
You need to be logged in to leave comments. Login now