summaryrefslogtreecommitdiff
path: root/string_utils.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2021-09-15 09:32:08 -0700
committerScott Gasch <[email protected]>2021-09-15 09:32:08 -0700
commit4c315e387f18010ba0b5661744ad3c792f21d2d1 (patch)
treea5657340bea356aa3aaf2c24b7f2be98bb4bc302 /string_utils.py
parent83c1e0d04fe2e78963c8b508e8b7d0ae03bfcb16 (diff)
Adding doctests. Also added a logging filter.
Diffstat (limited to 'string_utils.py')
-rw-r--r--string_utils.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/string_utils.py b/string_utils.py
index 0829846..3aaf1d7 100644
--- 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('1')
True
+
>>> to_bool('yes')
True
+
>>> to_bool('no')
False
+
>>> to_bool('huh?')
False
+
+ >>> to_bool('on')
+ True
+
"""
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]: