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)
| 654 | return _coerce_result(_urlunsplit(scheme, netloc, url, query, fragment)) |
| 655 | |
| 656 | def 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 | |
| 683 | def _urlunsplit(scheme, netloc, url, query, fragment): |
| 684 | if netloc is not None: |
searching dependent graphs…