MCPcopy
hub / github.com/caronc/apprise / parse_bool

Function parse_bool

apprise/utils/parse.py:859–900  ·  view source on GitHub ↗

Support string based boolean settings. If the content could not be parsed, then the default is returned.

(arg, default=False)

Source from the content-addressed store, hash-verified

857
858
859def parse_bool(arg, default=False):
860 """Support string based boolean settings.
861
862 If the content could not be parsed, then the default is returned.
863 """
864
865 if isinstance(arg, str):
866 # no = no - False
867 # of = short for off - False
868 # 0 = int for False
869 # fa = short for False - False
870 # f = short for False - False
871 # n = short for No or Never - False
872 # ne = short for Never - False
873 # di = short for Disable(d) - False
874 # de = short for Deny - False
875 if arg.lower()[0:2] in (
876 "de",
877 "di",
878 "ne",
879 "f",
880 "n",
881 "no",
882 "of",
883 "0",
884 "fa",
885 ):
886 return False
887 # ye = yes - True
888 # on = short for off - True
889 # 1 = int for True
890 # tr = short for True - True
891 # t = short for True - True
892 # al = short for Always (and Allow) - True
893 # en = short for Enable(d) - True
894 elif arg.lower()[0:2] in ("en", "al", "t", "y", "ye", "on", "1", "tr"):
895 return True
896 # otherwise
897 return default
898
899 # Handle other types
900 return bool(arg)
901
902
903def parse_domain_service_targets(

Callers 15

__init__Method · 0.85
parse_urlMethod · 0.85
parse_urlMethod · 0.85
parse_urlMethod · 0.85
parse_urlMethod · 0.85
parse_urlMethod · 0.85
parse_urlMethod · 0.85
parse_urlMethod · 0.85
__init__Method · 0.85
parse_urlMethod · 0.85
parse_urlMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…