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

Method parse_url

apprise/plugins/apprise_api.py:503–553  ·  view source on GitHub ↗

Parses the URL and returns enough arguments that can allow us to re- instantiate this object.

(url)

Source from the content-addressed store, hash-verified

501
502 @staticmethod
503 def parse_url(url):
504 """Parses the URL and returns enough arguments that can allow us to re-
505 instantiate this object."""
506 results = NotifyBase.parse_url(url)
507 if not results:
508 # We're done early as we couldn't load the results
509 return results
510
511 # Add our headers that the user can potentially over-ride if they wish
512 # to to our returned result set and tidy entries by unquoting them
513 results["headers"] = {
514 NotifyAppriseAPI.unquote(x): NotifyAppriseAPI.unquote(y)
515 for x, y in results["qsd+"].items()
516 }
517
518 # Support the passing of tags in the URL
519 if "tags" in results["qsd"] and len(results["qsd"]["tags"]):
520 results["tags"] = NotifyAppriseAPI.parse_list(
521 results["qsd"]["tags"]
522 )
523
524 # Support the 'to' & 'token' variable so that we can support rooms
525 # this way too.
526 if "token" in results["qsd"] and len(results["qsd"]["token"]):
527 results["token"] = NotifyAppriseAPI.unquote(
528 results["qsd"]["token"]
529 )
530
531 elif "to" in results["qsd"] and len(results["qsd"]["to"]):
532 results["token"] = NotifyAppriseAPI.unquote(results["qsd"]["to"])
533
534 else:
535 # Start with a list of path entries to work with
536 entries = NotifyAppriseAPI.split_path(results["fullpath"])
537 if entries:
538 # use our last entry found
539 results["token"] = entries[-1]
540
541 # pop our last entry off
542 entries = entries[:-1]
543
544 # re-assemble our full path
545 results["fullpath"] = "/".join(entries)
546
547 # Set method if specified
548 if "method" in results["qsd"] and len(results["qsd"]["method"]):
549 results["method"] = NotifyAppriseAPI.unquote(
550 results["qsd"]["method"]
551 )
552
553 return results

Callers 1

parse_native_urlMethod · 0.45

Calls 4

unquoteMethod · 0.80
parse_listMethod · 0.80
split_pathMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected