def to_boolean(choice, default=False):
"""Convert the yes/no to true/false
:param choice: the text string input
:type choice: string
"""
if type(choice) == types.BooleanType:
return choice
valid = {"True": True, "true": True, "yes":True, "ye":True, "y":True,
"False":False, "false":False, "no":False, "n":False}
choice_lower = choice.lower()
if choice_lower in valid:
return valid[choice_lower]
return default
评论列表
文章目录