Only the first line is checked!"""
if not type(text) is list:
+ document.warning("You should pass a list to add_to_preamble!")
# split on \n just in case
# it'll give us the one element list we want
# if there's no \n, too
""" Insert text to the preamble at a given line"""
if not type(text) is list:
+ document.warning("You should pass a list to insert_to_preamble!")
# split on \n just in case
# it'll give us the one element list we want
# if there's no \n, too
def hex2ratio(s):
+ " Converts an RRGGBB-type hexadecimal string to a float in [0.0,1.0] "
try:
val = int(s, 16)
except:
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"