Removes any existing fragment from URL. Returns a tuple of the defragmented URL and the fragment. If the URL contained no fragments, the second element is the empty string or None if missing_as_none is True.
(url, *, missing_as_none=_MISSING_AS_NONE_DEFAULT)
| 767 | |
| 768 | |
| 769 | def urldefrag(url, *, missing_as_none=_MISSING_AS_NONE_DEFAULT): |
| 770 | """Removes any existing fragment from URL. |
| 771 | |
| 772 | Returns a tuple of the defragmented URL and the fragment. If |
| 773 | the URL contained no fragments, the second element is the |
| 774 | empty string or None if missing_as_none is True. |
| 775 | """ |
| 776 | url, _coerce_result = _coerce_args(url) |
| 777 | if '#' in url: |
| 778 | s, n, p, q, frag = _urlsplit(url) |
| 779 | defrag = _urlunsplit(s, n, p, q, None) |
| 780 | else: |
| 781 | frag = None |
| 782 | defrag = url |
| 783 | if not missing_as_none and frag is None: frag = '' |
| 784 | result = _coerce_result(DefragResult(defrag, frag)) |
| 785 | result._keep_empty = missing_as_none |
| 786 | return result |
| 787 | |
| 788 | _hexdig = '0123456789ABCDEFabcdef' |
| 789 | _hextobyte = None |
searching dependent graphs…