MCPcopy Index your code
hub / github.com/python/cpython / urlunsplit

Function urlunsplit

Lib/urllib/parse.py:656–681  ·  view source on GitHub ↗

Combine the elements of a tuple as returned by urlsplit() into a complete URL as a string. The data argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with

(components, *, keep_empty=_UNSPECIFIED)

Source from the content-addressed store, hash-verified

654 return _coerce_result(_urlunsplit(scheme, netloc, url, query, fragment))
655
656def urlunsplit(components, *, keep_empty=_UNSPECIFIED):
657 """Combine the elements of a tuple as returned by urlsplit() into a
658 complete URL as a string. The data argument can be any five-item iterable.
659 This may result in a slightly different, but equivalent URL, if the URL that
660 was parsed originally had unnecessary delimiters (for example, a ? with an
661 empty query; the RFC states that these are equivalent) and keep_empty
662 is false or components is the result of the urlsplit() call with
663 missing_as_none=False."""
664 scheme, netloc, url, query, fragment, _coerce_result = (
665 _coerce_args(*components))
666 if keep_empty is _UNSPECIFIED:
667 keep_empty = getattr(components, '_keep_empty', _MISSING_AS_NONE_DEFAULT)
668 elif keep_empty and not getattr(components, '_keep_empty', True):
669 raise ValueError('Cannot distinguish between empty and not defined '
670 'URI components in the result of parsing URL with '
671 'missing_as_none=False')
672 if not keep_empty:
673 if not netloc:
674 if scheme and scheme in uses_netloc and (not url or url[:1] == '/'):
675 netloc = ''
676 else:
677 netloc = None
678 if not scheme: scheme = None
679 if not query: query = None
680 if not fragment: fragment = None
681 return _coerce_result(_urlunsplit(scheme, netloc, url, query, fragment))
682
683def _urlunsplit(scheme, netloc, url, query, fragment):
684 if netloc is not None:

Callers 4

checkRoundtripsMethod · 0.90
checkRoundtrips1Method · 0.90
checkJoinMethod · 0.90
geturlMethod · 0.85

Calls 2

_coerce_argsFunction · 0.85
_urlunsplitFunction · 0.85

Tested by 3

checkRoundtripsMethod · 0.72
checkRoundtrips1Method · 0.72
checkJoinMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…