URLSpec

from panda3d.core import URLSpec
class URLSpec

Bases:

A container for a URL, e.g. “http://server:port/path”.

The URLSpec object is similar to a Filename in that it contains logic to identify the various parts of a URL and return (or modify) them separately.

Inheritance diagram

Inheritance diagram of URLSpec

__eq__(other: URLSpec) bool
__getitem__(n: int) char
__init__()
__init__(param0: URLSpec)
__init__(url: URLSpec, path: Filename)

Creates a URLSpec by appending a path to the end of the old URLSpec, inserting an intervening forward slash if necessary.

__init__(url: str, server_name_expected: bool)
__lt__(other: URLSpec) bool
__ne__(other: URLSpec) bool
assign(url: str) URLSpec
property authority string
Getter

Returns the authority specified by the URL (this includes username, server, and/or port), or empty string if no authority is specified.

Setter

Replaces the authority part of the URL specification. This includes the username, server, and port.

c_str() str
compare_to(other: URLSpec) int

Returns a number less than zero if this URLSpec sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent.

empty() bool

Returns false if the URLSpec is valid (not empty), or true if it is an empty string.

get_authority() str

Returns the authority specified by the URL (this includes username, server, and/or port), or empty string if no authority is specified.

static get_default_port_for_scheme(scheme: str) int

Returns the default port number for the indicated scheme, or 0 if there is no known default.

get_hash() int
get_path() str

Returns the path specified by the URL, or “/” if no path is specified.

get_path_and_query() str

Returns the path (or “/” if no path is specified), followed by the query if it is specified.

get_port() int

Returns the port number specified by the URL, or the default port if not specified.

get_port_str() str

Returns the port specified by the URL as a string, or the empty string if no port is specified. Compare this with get_port(), which returns a default port number if no port is specified.

get_query() str

Returns the query specified by the URL, or empty string if no query is specified.

get_scheme() str

Returns the scheme specified by the URL, or empty string if no scheme is specified.

get_server() str

Returns the server name specified by the URL, if any. In case of an IPv6 address, does not include the enclosing brackets.

get_server_and_port() str

Returns a string consisting of the server name, followed by a colon, followed by the port number. If the port number is not explicitly given in the URL, this string will include the implicit port number. If the server is an IPv6 address, it will be enclosed in square brackets.

get_url() str

Returns the complete URL specification.

get_username() str

Returns the username specified by the URL, if any. This might also include a password, e.g. “username:password”, although putting a password on the URL is probably a bad idea.

has_authority() bool

Returns true if the URL specifies an authority (this includes username, server, and/or port), false otherwise.

has_path() bool

Returns true if the URL includes a path specification (that is, the particular filename on the server to retrieve), false otherwise.

has_port() bool

Returns true if the URL specifies a port number, false otherwise.

has_query() bool

Returns true if the URL includes a query specification, false otherwise.

has_scheme() bool

Returns true if the URL specifies a scheme (e.g. “http:”), false otherwise.

has_server() bool

Returns true if the URL specifies a server name, false otherwise.

has_username() bool

Returns true if the URL specifies a username (and/or password), false otherwise.

input(in: istream) bool
is_default_port() bool

Returns true if the port number encoded in this URL is the default port number for the scheme (or if there is no port number), or false if it is a nonstandard port.

is_ssl() bool

Returns true if the URL’s scheme specifies an SSL-secured protocol such as https, or false otherwise.

length() int
output(out: ostream)
property path string
Getter

Returns the path specified by the URL, or “/” if no path is specified.

Setter

Replaces the path part of the URL specification.

property port int
Getter

Returns the port number specified by the URL, or the default port if not specified.

Setter

Replaces the port part of the URL specification.

Replaces the port part of the URL specification, given a numeric port number.

property query string
Getter

Returns the query specified by the URL, or empty string if no query is specified.

Setter

Replaces the query part of the URL specification.

static quote(source: str, safe: str) str

Returns the source string with all “unsafe” characters quoted, making a string suitable for placing in a URL. Letters, digits, and the underscore, comma, period, and hyphen characters, as well as any included in the safe string, are left alone; all others are converted to hex representation.

static quote_plus(source: str, safe: str) str

Behaves like quote() with the additional behavior of replacing spaces with plus signs.

property scheme string
Getter

Returns the scheme specified by the URL, or empty string if no scheme is specified.

Setter

Replaces the scheme part of the URL specification.

property server string
Getter

Returns the server name specified by the URL, if any. In case of an IPv6 address, does not include the enclosing brackets.

Setter

Replaces the server part of the URL specification. Unlike set_server_and_port(), this method does not require IPv6 addresses to be enclosed in square brackets.

property server_and_port string
Getter

Returns a string consisting of the server name, followed by a colon, followed by the port number. If the port number is not explicitly given in the URL, this string will include the implicit port number. If the server is an IPv6 address, it will be enclosed in square brackets.

Setter

Replaces the server and port parts of the URL specification simultaneously. The input string should be of the form “server:port”, or just “server” to make the port number implicit. Any IPv6 address must be enclosed in square brackets.

set_authority(authority: str)

Replaces the authority part of the URL specification. This includes the username, server, and port.

set_path(path: str)

Replaces the path part of the URL specification.

set_port(port: str)

Replaces the port part of the URL specification.

set_port(port: int)

Replaces the port part of the URL specification, given a numeric port number.

set_query(query: str)

Replaces the query part of the URL specification.

set_scheme(scheme: str)

Replaces the scheme part of the URL specification.

set_server(server: str)

Replaces the server part of the URL specification. Unlike set_server_and_port(), this method does not require IPv6 addresses to be enclosed in square brackets.

set_server_and_port(server_and_port: str)

Replaces the server and port parts of the URL specification simultaneously. The input string should be of the form “server:port”, or just “server” to make the port number implicit. Any IPv6 address must be enclosed in square brackets.

set_url(url: str, server_name_expected: bool)

Completely replaces the URL with the indicated string. If server_name_expected is true, it is a hint that an undecorated URL is probably a server name, not a local filename.

set_username(username: str)

Replaces the username part of the URL specification.

size() int
property ssl bool

Returns true if the URL’s scheme specifies an SSL-secured protocol such as https, or false otherwise.

static unquote(source: str) str

Reverses the operation of quote(): converts escaped characters of the form “%xx” to their ascii equivalent.

static unquote_plus(source: str) str

Reverses the operation of quote_plus(): converts escaped characters of the form “%xx” to their ascii equivalent, and also converts plus signs to spaces.

property username string
Getter

Returns the username specified by the URL, if any. This might also include a password, e.g. “username:password”, although putting a password on the URL is probably a bad idea.

Setter

Replaces the username part of the URL specification.