mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-24 17:09:41 +00:00
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:
parent
cd99f162b3
commit
645f3f20b3
@ -352,6 +352,7 @@ def revert_layout_command(document, name, LaTeXname, position):
|
|||||||
|
|
||||||
|
|
||||||
def hex2ratio(s):
|
def hex2ratio(s):
|
||||||
|
" Converts an RRGGBB-type hexadecimal string to a float in [0.0,1.0] "
|
||||||
try:
|
try:
|
||||||
val = int(s, 16)
|
val = int(s, 16)
|
||||||
except:
|
except:
|
||||||
@ -360,3 +361,9 @@ def hex2ratio(s):
|
|||||||
val += 1
|
val += 1
|
||||||
return str(val / 256.0)
|
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"
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user