Attention

You are looking at outdated documentation for version 2.x. A newer version is available.

wsgidav.compat

Description

Tool functions to support Python 2 and 3.

Inspired by six https://pythonhosted.org/six/

Functions

is_basestring(s) Return True for any string type (for str/unicode on Py2 and bytes/str on Py3).
is_bytes(s) Return True for bytestrings (for str on Py2 and bytes on Py3).
is_native(s) Return True for native strings (for str on Py2 and Py3).
is_unicode(s) Return True for unicode strings (for unicode on Py2 and str on Py3).
to_bytes(s[, encoding]) Convert unicode (text strings) to binary data (str on Py2 and bytes on Py3).
to_native(s[, encoding]) Convert data to native str type (bytestring on Py2 and unicode on Py3).
to_unicode(s[, encoding]) Convert binary data to unicode (text strings) on Python 2 and 3.
unicode_to_wsgi(u) Convert an environment variable to a WSGI ‘bytes-as-unicode’ string.
wsgi_to_bytes(s) Convert a native string to a WSGI / HTTP compatible byte string.

Other Members

BytesIO StringIO([s]) – Return a StringIO-like stream for reading or writing
PY2 True if we are running on Python 2.x
PY3 True if we are running on Python 3
StringIO StringIO([s]) – Return a StringIO-like stream for reading or writing
b_empty str(object=’‘) -> string
b_slash str(object=’‘) -> string
base64_decodebytes(s) Decode a string.
base64_encodebytes(s) Encode a string into multiple lines of base-64 data.
console_input raw_input([prompt]) -> string
html_escape(s[, quote]) Replace special characters “&”, “<” and “>” to HTML-safe sequences.
queue A multi-producer, multi-consumer queue.
quote() Each part of a URL, e.g.
sys This module provides access to some objects used or maintained by the interpreter and to functions that interact strongly with the interpreter.
unquote()
urlparse(url[, scheme, allow_fragments]) Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
xrange(stop) xrange(start, stop[, step]) -> xrange object