Moved toBool to go before format in utils/str.py.

This commit is contained in:
Jeremy Fincher 2005-01-28 15:21:03 +00:00
parent 34f1fe6562
commit 90e901702b

View File

@ -318,7 +318,15 @@ def has(i):
else: else:
return 'have' return 'have'
_formatRe = re.compile('%([isfbhL])') def toBool(s):
s = s.strip().lower()
if s in ('true', 'on', 'enable', 'enabled', '1'):
return True
elif s in ('false', 'off', 'disable', 'disabled', '0'):
return False
else:
raise ValueError, 'Invalid string for toBool: %s' % quoted(s)
def format(s, *args, **kwargs): def format(s, *args, **kwargs):
kwargs.setdefault('decimalSeparator', decimalSeparator) kwargs.setdefault('decimalSeparator', decimalSeparator)
kwargs.setdefault('thousandsSeparator', thousandsSeparator) kwargs.setdefault('thousandsSeparator', thousandsSeparator)
@ -344,13 +352,4 @@ def format(s, *args, **kwargs):
assert False, 'Invalid char in sub (in format).' assert False, 'Invalid char in sub (in format).'
return _formatRe.sub(sub, s) return _formatRe.sub(sub, s)
def toBool(s):
s = s.strip().lower()
if s in ('true', 'on', 'enable', 'enabled', '1'):
return True
elif s in ('false', 'off', 'disable', 'disabled', '0'):
return False
else:
raise ValueError, 'Invalid string for toBool: %s' % quoted(s)
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: