Change boolean config option parsing to allow True and Y and similar useful

things.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
emellor@ewan committed 2005-10-05 17:48:36 +01:00
1 parent 66c12e28e9
commit d4d9c86a25
1 file changed
+4 -3
+4 -3
View File
@@ -26,6 +26,7 @@ configured values.
import os
import os.path
import string
import sys
from XendLogging import XendLogging
@@ -238,10 +239,10 @@ class XendRoot:
return sxp.child_value(self.config, name, val=val)
def get_config_bool(self, name, val=None):
v = self.get_config_value(name, val)
if v in ['yes', '1', 'on', 'true', 1, True]:
v = string.lower(str(self.get_config_value(name, val)))
if v in ['yes', 'y', '1', 'on', 'true', 't']:
return True
if v in ['no', '0', 'off', 'false', 0, False]:
if v in ['no', 'n', '0', 'off', 'false', 'f']:
return False
raise XendError("invalid xend config %s: expected bool: %s" % (name, v))
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.