mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-24 03:29:28 +01:00
Moved toBool to go before format in utils/str.py.
This commit is contained in:
parent
34f1fe6562
commit
90e901702b
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user