Code review feedback.
This commit is contained in:
@@ -2,14 +2,11 @@
|
||||
Utilities for string manipulation.
|
||||
"""
|
||||
|
||||
import ast
|
||||
|
||||
def str_to_bool(str):
|
||||
"""
|
||||
Converts "true" (case-insensitive) to the boolean True.
|
||||
Everything else will return False.
|
||||
Everything else will return False (including None).
|
||||
|
||||
An error will be thrown for non-string input (besides None).
|
||||
"""
|
||||
try:
|
||||
return ast.literal_eval(str.title())
|
||||
except:
|
||||
return False
|
||||
return False if str is None else str.lower() == "true"
|
||||
|
||||
Reference in New Issue
Block a user