wsgidav.compat

Description

Tool functions to support Python 2 and 3.

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

TODO: since it is now based on six, we should remove this module eventually.

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 a text string (unicode) to bytestring (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 Buffered I/O implementation using an in-memory bytes buffer.
PY2 bool(x) -> bool
PY3 bool(x) -> bool
StringIO Text I/O implementation using an in-memory buffer.
b_empty bytes(iterable_of_ints) -> bytes bytes(string, encoding[, errors]) -> bytes bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer bytes(int) -> bytes object of size given by the parameter initialized with null bytes bytes() -> empty bytes object
b_slash bytes(iterable_of_ints) -> bytes bytes(string, encoding[, errors]) -> bytes bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer bytes(int) -> bytes object of size given by the parameter initialized with null bytes bytes() -> empty bytes object
base64_decodebytes(s) Decode a bytestring of base-64 data into a bytes object.
base64_encodebytes(s) Encode a bytestring into a bytes object containing multiple lines of base-64 data.
collections_abc
console_input Read a string from standard input.
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.
six Utilities for writing code that runs on Python 2 and 3
sys This module provides access to some objects used or maintained by the interpreter and to functions that interact strongly with the interpreter.
unquote(string[, encoding, errors]) Replace %xx escapes by their single-character equivalent.
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 alias of builtins.range