requirementslib.models.url module

class requirementslib.models.url.URI(host: str, scheme: str = 'https', port: int = None, path: str = '', query: str = '', fragment: str = '', subdirectory: str = '', ref: str = '', username: str = '', password: str = '', query_dict: orderedmultidict.orderedmultidict.omdict = NOTHING, name: str = '', extras: tuple = NOTHING, is_direct_url: bool = False, is_implicit_ssh: bool = False, auth: str = None, fragment_dict: dict = NOTHING, username_is_quoted: bool = False, password_is_quoted: bool = False)[source]

Bases: object

bare_url
base_url
extras = None

Any extras requested from the requirement

fragment = None

URL Fragments, e.g. #fragment=value

full_url
get_host_port_path(strip_ref=False)[source]
classmethod get_parsed_url(url)[source]
get_password(unquote=False, include_token=True)[source]
get_username(unquote=False)[source]
hidden_auth
host = None

The target hostname, e.g. amazon.com

is_direct_url = None

Whether the url was parsed as a direct pep508-style URL

is_file_url
is_implicit_ssh = None

Whether the url was an implicit git+ssh url (passed as git+git@)

is_installable
is_vcs
name = None

The name of the specified package in case it is a VCS URI with an egg fragment

name_with_extras
classmethod parse(url)[source]
static parse_subdirectory(url_part)[source]
password = None

Password parsed from user:password@hostname

path = None

The url path, e.g. /path/to/endpoint

port = None

The numeric port of the url if specified

query = None

Query parameters, e.g. ?variable=value…

query_dict = None

An orderedmultidict representing query fragments

ref = None

VCS ref this URI points at, if available

safe_string
scheme = None

The URI Scheme, e.g. salesforce

secret
subdirectory = None

Subdirectory fragment, e.g. &subdirectory=blah…

to_string(escape_password=True, unquote=True, direct=None, strip_ssh=False, strip_ref=False, strip_name=False, strip_subdir=False)[source]

Converts the current URI to a string, unquoting or escaping the password as needed.

Parameters:
  • escape_password – Whether to replace password with ----, default True
  • escape_password – bool, optional
  • unquote – Whether to unquote url-escapes in the password, default False
  • unquote – bool, optional
  • direct (bool) – Whether to format as a direct URL
  • strip_ssh (bool) – Whether to strip the SSH scheme from the url (git only)
  • strip_ref (bool) – Whether to drop the VCS ref (if present)
  • strip_name (bool) – Whether to drop the name and extras (if present)
  • strip_subdir (bool) – Whether to drop the subdirectory (if present)
Returns:

The reconstructed string representing the URI

Return type:

str

unsafe_string
uri_escape
url_without_fragment
url_without_fragment_or_ref
url_without_ref
username = None

The username if provided, parsed from user:password@hostname

requirementslib.models.url.remove_password_from_url(url)[source]

Given a url, remove the password and insert 4 dashes.

Parameters:url (S) – The url to replace the authentication in
Returns:The new URL without authentication
Return type:S
requirementslib.models.url.update_url_name_and_fragment(name_with_extras, ref, parsed_dict)[source]