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

Method url

apprise/url.py:354–392  ·  view source on GitHub ↗

Assembles the URL associated with the notification based on the arguments provied.

(self, privacy=False, *args, **kwargs)

Source from the content-addressed store, hash-verified

352 return
353
354 def url(self, privacy=False, *args, **kwargs):
355 """Assembles the URL associated with the notification based on the
356 arguments provied."""
357
358 # Our default parameters
359 params = self.url_parameters(privacy=privacy, *args, **kwargs)
360
361 # Determine Authentication
362 auth = ""
363 if self.user and self.password:
364 auth = "{user}:{password}@".format(
365 user=URLBase.quote(self.user, safe=""),
366 password=self.pprint(
367 self.password, privacy, mode=PrivacyMode.Secret, safe=""
368 ),
369 )
370 elif self.user:
371 auth = "{user}@".format(
372 user=URLBase.quote(self.user, safe=""),
373 )
374
375 default_port = 443 if self.secure else 80
376 return "{schema}://{auth}{hostname}{port}{fullpath}{params}".format(
377 schema="https" if self.secure else "http",
378 auth=auth,
379 # never encode hostname since we're expecting it to be a valid one
380 hostname=self.host,
381 port=(
382 ""
383 if self.port is None or self.port == default_port
384 else f":{self.port}"
385 ),
386 fullpath=(
387 URLBase.quote(self.fullpath, safe="/")
388 if self.fullpath
389 else "/"
390 ),
391 params=("?" + URLBase.urlencode(params) if params else ""),
392 )
393
394 def url_id(self, lazy=True, hash_engine=hashlib.sha256):
395 """Returns a unique URL identifier that representing the Apprise URL

Callers 7

__str__Method · 0.95
instantiateMethod · 0.45
urlsMethod · 0.45
__getstate__Method · 0.45
mainFunction · 0.45
addMethod · 0.45

Calls 4

url_parametersMethod · 0.95
pprintMethod · 0.95
quoteMethod · 0.80
urlencodeMethod · 0.80

Tested by 1