New str2bool() utility. Python's own bool() returns True for any but an

empty string....


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36104 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-11-05 14:27:30 +00:00
parent cd99f162b3
commit 645f3f20b3

View File

@ -352,6 +352,7 @@ def revert_layout_command(document, name, LaTeXname, position):
def hex2ratio(s):
" Converts an RRGGBB-type hexadecimal string to a float in [0.0,1.0] "
try:
val = int(s, 16)
except:
@ -360,3 +361,9 @@ def hex2ratio(s):
val += 1
return str(val / 256.0)
def str2bool(s):
"'true' goes to True, case-insensitively, and we strip whitespace."
s = s.strip().lower()
return s == "true"