projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve persistent after actually using it.
[python_utils.git]
/
string_utils.py
diff --git
a/string_utils.py
b/string_utils.py
index 0829846bb26741bfb0c8bdd0226d56511fc31bbd..3aaf1d7efe4151c61a1739af72234abc0a69fbc3 100644
(file)
--- a/
string_utils.py
+++ b/
string_utils.py
@@
-1059,18
+1059,26
@@
def to_bool(in_str: str) -> bool:
>>> to_bool('True')
True
>>> to_bool('True')
True
+
>>> to_bool('1')
True
>>> to_bool('1')
True
+
>>> to_bool('yes')
True
>>> to_bool('yes')
True
+
>>> to_bool('no')
False
>>> to_bool('no')
False
+
>>> to_bool('huh?')
False
>>> to_bool('huh?')
False
+
+ >>> to_bool('on')
+ True
+
"""
if not is_string(in_str):
raise ValueError(in_str)
"""
if not is_string(in_str):
raise ValueError(in_str)
- return in_str.lower() in ("true", "1", "yes", "y", "t")
+ return in_str.lower() in ("true", "1", "yes", "y", "t"
, "on"
)
def to_date(in_str: str) -> Optional[datetime.date]:
def to_date(in_str: str) -> Optional[datetime.date]: