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

Function parse_phone_no

apprise/utils/parse.py:945–976  ·  view source on GitHub ↗

Takes a string containing phone numbers separated by comma's and/or spaces and returns a list.

(*args, store_unparseable=True, prefix=False, **kwargs)

Source from the content-addressed store, hash-verified

943
944
945def parse_phone_no(*args, store_unparseable=True, prefix=False, **kwargs):
946 """Takes a string containing phone numbers separated by comma's and/or
947 spaces and returns a list."""
948
949 result = []
950 for arg in args:
951 if isinstance(arg, str) and arg:
952 result_ = (
953 PHONE_NO_DETECTION_RE
954 if not prefix
955 else PHONE_NO_WPREFIX_DETECTION_RE
956 ).findall(arg)
957 if result_:
958 result += result_
959
960 elif not result_ and store_unparseable:
961 # we had content passed into us that was lost because it was
962 # so poorly formatted that it didn't even come close to
963 # meeting the regular expression we defined. We intentially
964 # keep it as part of our result set so that parsing done
965 # at a higher level can at least report this to the end user
966 # and hopefully give them some indication as to what they
967 # may have done wrong.
968 result += list(filter(bool, re.split(STRING_DELIMITERS, arg)))
969
970 elif isinstance(arg, (set, list, tuple)):
971 # Use recursion to handle the list of phone numbers
972 result += parse_phone_no(
973 *arg, store_unparseable=store_unparseable, prefix=prefix
974 )
975
976 return result
977
978
979def parse_call_sign(*args, store_unparseable=True, **kwargs):

Callers 15

parse_phone_noMethod · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…