pyurl

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIPv6 = errors.New("Invalid IPv6 URL")

ErrInvalidIPv6 is the ValueError urlsplit raises for unbalanced or malformed brackets

View Source
var ErrPortOutOfRange = errors.New("Port out of range 0-65535")

ErrPortOutOfRange is the ValueError SplitResult.port raises past 65535

View Source
var UsesParams = map[string]bool{"": true, "ftp": true, "hdl": true, "prospero": true, "http": true, "imap": true, "https": true,
	"shttp": true, "rtsp": true, "rtsps": true, "rtspu": true, "sip": true, "sips": true, "mms": true, "sftp": true, "tel": true}
View Source
var UsesRelative = map[string]bool{"": true, "ftp": true, "http": true, "gopher": true, "nntp": true, "imap": true, "wais": true,
	"file": true, "https": true, "shttp": true, "mms": true, "prospero": true, "rtsp": true, "rtsps": true, "rtspu": true,
	"sftp": true, "svn": true, "svn+ssh": true, "ws": true, "wss": true}

Functions

func BaseURLHostMatches

func BaseURLHostMatches(baseURL, domain string) (bool, error)

Reports whether the base URL hostname is the domain or one of its subdomains

func BaseURLHostname

func BaseURLHostname(baseURL string) (string, error)

Lowercased hostname of a base URL that may lack a scheme, the urlparse ValueError on a bad netloc

func BaseURLOrigin

func BaseURLOrigin(baseURL string) (string, string, int, error)

Scheme, lowercased hostname and effective port of a base URL, empty with port 0 on no host or a bad port

func BaseURLPath

func BaseURLPath(baseURL string) (string, error)

Lowercased path of a base URL without trailing slashes, empty for a bare host, the urlparse ValueError on a bad netloc

func EnvironProxies

func EnvironProxies(environ []string) map[string]string

Scheme to proxy map read from the environment the way urllib getproxies_environment reads it

func EnvironUrlopenProxy

func EnvironUrlopenProxy(environ []string, req *http.Request) (*url.URL, error)

Urlopen proxy choice over an explicit environment in place of the process one

func FormatURLHost

func FormatURLHost(host string) string

Host in HTTP URL authority form, bracketing IPv6 literals and escaping a zone percent

func Getproxies

func Getproxies() map[string]string

Environment proxies, or the operating system ones when the environment sets none, as urllib getproxies reads them

func Join

func Join(base, ref string) (string, error)

Resolves a reference against a base URL like urllib.parse.urljoin of CPython 3.14

func ParseQS

func ParseQS(qs string, keepBlankValues bool) map[string][]string

Values per name in first seen order as urllib.parse.parse_qs groups them

func ParseQSL

func ParseQSL(qs string, keepBlankValues bool) [][2]string

Name value pairs of a query string as urllib.parse.parse_qsl splits and unquotes them, non strict

func ProxyBypassEnvironment

func ProxyBypassEnvironment(host string, proxies map[string]string) bool

Reports whether no_proxy exempts the host the way urllib proxy_bypass_environment decides

func Quote

func Quote(s, safe string) string

Percent encodes UTF-8 bytes like urllib.parse.quote, keeping letters, digits, _.-~ and the safe set

func QuotePlus

func QuotePlus(s, safe string) string

Percent encodes like urllib.parse.quote_plus, spaces becoming plus signs

func SystemProxies

func SystemProxies() map[string]string

No operating system proxy source outside macOS and Windows

func URL2Pathname

func URL2Pathname(url string, requireScheme, resolveHost bool) (string, error)

Local path of a file URL like urllib.request.url2pathname, a WTF-8 str decoded with the fs error handler

func URLEncode

func URLEncode(pairs [][2]string) string

Query string of ordered string pairs like urllib.parse.urlencode with its quote_plus default

func Unparse

func Unparse(u URL) string

Reassembles parsed parts like urllib.parse.urlunparse, params rejoined to the path

func Unquote

func Unquote(s string) string

Percent decodes like urllib.parse.unquote, ASCII runs as UTF-8 with replacement and other text kept

func UnquoteLatin1

func UnquoteLatin1(s string) string

Percent decodes like urllib.parse.unquote with encoding latin-1, each decoded byte becoming the same code point

func Unsplit

func Unsplit(u URL) string

Reassembles split parts like urllib.parse.urlunsplit, empty query and fragment dropped

func UrlopenProxy

func UrlopenProxy(req *http.Request) (*url.URL, error)

Transport proxy choice of urllib urlopen on posix, environment proxies without a loopback exemption

Types

type URL

type URL struct {
	Scheme, Netloc, Path, Params, Query, Fragment string
}

URL holds the parts urllib.parse splits a URL into, params apart from the path

func Parse

func Parse(raw string) (URL, error)

Parses like urllib.parse.urlparse, moving the last segment's params out of the path

func Split

func Split(raw string) (URL, error)

Splits like urllib.parse.urlsplit including its control stripping and bracket checks

func (URL) Hostname

func (u URL) Hostname() string

Hostname of the netloc like SplitResult.hostname, lowercased with any zone kept, empty when absent

func (URL) Port

func (u URL) Port() (int, bool, error)

Port of the netloc like SplitResult.port, absent when empty, the ValueError when not an ASCII number in range

type URLError

type URLError struct{ Reason string }

URLError is urllib.error.URLError, its reason wrapped in the urlopen error brackets

func (*URLError) Error

func (e *URLError) Error() string

func (*URLError) PyTypeName

func (e *URLError) PyTypeName() string

Python exception class name the error stands for

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL