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

Function urlparse

Lib/urllib/parse.py:447–482  ·  view source on GitHub ↗

Parse a URL into 6 components: :// / ; ? # The result is a named 6-tuple with fields corresponding to the above. It is either a ParseResult or ParseResultBytes object, depending on the type of the url parameter. The username, password,

(url, scheme=None, allow_fragments=True, *, missing_as_none=_MISSING_AS_NONE_DEFAULT)

Source from the content-addressed store, hash-verified

445del _fix_result_transcoding
446
447def urlparse(url, scheme=None, allow_fragments=True, *, missing_as_none=_MISSING_AS_NONE_DEFAULT):
448 """Parse a URL into 6 components:
449 <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
450
451 The result is a named 6-tuple with fields corresponding to the
452 above. It is either a ParseResult or ParseResultBytes object,
453 depending on the type of the url parameter.
454
455 The username, password, hostname, and port sub-components of netloc
456 can also be accessed as attributes of the returned object.
457
458 The scheme argument provides the default value of the scheme
459 component when no scheme is found in url.
460
461 If allow_fragments is False, no attempt is made to separate the
462 fragment component from the previous component, which can be either
463 path or query.
464
465 Note that % escapes are not expanded.
466
467 urlsplit() should generally be used instead of urlparse().
468 """
469 url, scheme, _coerce_result = _coerce_args(url, scheme)
470 if url is None:
471 url = ''
472 scheme, netloc, url, params, query, fragment = _urlparse(url, scheme, allow_fragments)
473 if not missing_as_none:
474 if scheme is None: scheme = ''
475 if netloc is None: netloc = ''
476 if params is None: params = ''
477 if query is None: query = ''
478 if fragment is None: fragment = ''
479 result = ParseResult(scheme, netloc, url, params, query, fragment)
480 result = _coerce_result(result)
481 result._keep_empty = missing_as_none
482 return result
483
484def _urlparse(url, scheme=None, allow_fragments=True):
485 scheme, netloc, url, query, fragment = _urlsplit(url, scheme, allow_fragments)

Callers 11

handle_requestMethod · 0.90
checkRoundtripsMethod · 0.90
checkRoundtrips1Method · 0.90
test_RFC2368Method · 0.90
test_withoutschemeMethod · 0.90
test_portseparatorMethod · 0.90
test_anyschemeMethod · 0.90
request_hostFunction · 0.90
http_error_302Method · 0.90
http_error_401Method · 0.90

Calls 3

_coerce_argsFunction · 0.85
_urlparseFunction · 0.85
ParseResultClass · 0.85

Tested by 8

handle_requestMethod · 0.72
checkRoundtripsMethod · 0.72
checkRoundtrips1Method · 0.72
test_RFC2368Method · 0.72
test_withoutschemeMethod · 0.72
test_portseparatorMethod · 0.72
test_anyschemeMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…