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.

cStr() str
compareTo(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.

getAuthority() str

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

static getDefaultPortForScheme(scheme: str) int

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

getHash() int
getPath() str

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

getPathAndQuery() str

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

getPort() int

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

getPortStr() str

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

getQuery() str

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

getScheme() str

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

getServer() str

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

getServerAndPort() 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.

getUrl() str

Returns the complete URL specification.

getUsername() 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.

hasAuthority() bool

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

hasPath() bool

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

hasPort() bool

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

hasQuery() bool

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

hasScheme() bool

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

hasServer() bool

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

hasUsername() bool

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

input(in: istream) bool
isDefaultPort() 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.

isSsl() 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 quotePlus(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 setServerAndPort(), 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.

setAuthority(authority: str)

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

setPath(path: str)

Replaces the path part of the URL specification.

setPort(port: str)

Replaces the port part of the URL specification.

setPort(port: int)

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

setQuery(query: str)

Replaces the query part of the URL specification.

setScheme(scheme: str)

Replaces the scheme part of the URL specification.

setServer(server: str)

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

setServerAndPort(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.

setUrl(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.

setUsername(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 unquotePlus(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.