wsgidav.util#

Description

Miscellaneous support functions for WsgiDAV.

Classes

Functions

add_property_response(multistatus_elem, ...)

Append <response> element to <multistatus> element.

byte_number_string(number, *[, ...])

Convert bytes into human-readable representation.

calc_base64(s)

Return base64 encoded binarystring.

calc_hexdigest(s)

Return md5 digest for a string.

check_python_version(min_version)

Check for deprecated Python version.

check_tags(tags, known, *[, msg, ...])

Check if tags only contains known tags.

checked_etag(etag, *[, allow_none])

Validate etag string to ensure propare comparison.

deep_update(d, u)

dynamic_import_class(name)

Import a class from a module string, e.g. my.module.ClassName.

dynamic_instantiate_class(class_name, options, *)

Import a class and instantiate with custom args.

dynamic_instantiate_class_from_opts(options, *)

Import a class and instantiate with custom args.

evaluate_http_conditionals(dav_res, ...)

Handle 'If-...:' headers (but not 'If:' header).

fail(value[, context_info, src_exception, ...])

Wrapper to raise (and log) DAVError.

fix_path(path, root, *[, expand_vars, ...])

Convert path to absolute, expand and check.

get_content_length(environ)

Return a positive CONTENT_LENGTH in a safe way (return 0 otherwise).

get_dict_value(d, key_path[, default, as_dict])

Return the value of a nested dict using dot-notation path.

get_file_etag(file_path)

Return a strong, unquoted Entity Tag for a (file)path.

get_file_extension(path)

get_log_time([secs])

Return <secs> in log time format (pass secs=None for current date).

get_module_logger(moduleName, *[, ...])

Create a module logger, that can be en/disabled by configuration.

get_rfc1123_time([secs])

Return <secs> in rfc 1123 date/time format (pass secs=None for current date).

get_rfc3339_time([secs])

Return <secs> in RFC 3339 date/time format (pass secs=None for current date).

get_uri_name(uri)

Return local name, i.e. last segment of URI.

get_uri_parent(uri)

Return URI of parent collection with trailing '/', or None, if URI is top-level.

guess_mime_type(url)

Use the mimetypes module to lookup the type for an extension.

init_logging(config)

Initialize base logger named 'wsgidav'.

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_child_uri(parent_uri, child_uri)

Return True, if child_uri is a child of parent_uri.

is_equal_or_child_uri(parent_uri, child_uri)

Return True, if child_uri is a child of parent_uri or maps to the same resource.

is_str(s)

Return True for native strings (for str on Py2 and Py3).

join_uri(uri, *segments)

Append segments to URI.

make_complete_url(environ[, local_uri])

URL reconstruction according to PEP 333.

obtain_content_ranges(range_header, filesize)

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range

parse_if_header_dict(environ)

Parse HTTP_IF header into a dictionary and lists, and cache the result.

parse_if_match_header(value)

Return a list of etag-values for a If-Match or If-Not-Match header.

parse_time_string(timestring)

Return the number of seconds since the epoch, for a date/time string.

parse_xml_body(environ, *[, allow_empty])

Read request body XML into an etree.Element.

pop_path(path)

Return '/a/b/c' -> ('a', '/b/c').

pop_path2(path)

Return '/a/b/c' -> ('a', 'b', '/c').

purge_passwords(d, *[, in_place])

re_encode_wsgi(s, *[, encoding, fallback])

Convert a WSGI string to str, assuming the client used UTF-8.

read_and_discard_input(environ)

Read 1 byte from wsgi.input, if this has not been done yet.

read_timeout_value_header(timeoutvalue)

Return -1 if infinite, else return numofsecs.

removeprefix(s, prefix[, ignore_case])

Replacement for str.removeprefix() (Py3.9+) with ignore_case option.

safe_re_encode(s, encoding_to, *[, errors])

Re-encode str or binary so that is compatible with a given encoding (replacing unsupported chars).

save_split(s, sep, maxsplit)

Split string, always returning n-tuple (filled with None if necessary).

send_multi_status_response(environ, ...)

send_redirect_response(environ, ...)

Start a WSGI response for a DAVError or status code.

send_status_response(environ, ...[, ...])

Start a WSGI response for a DAVError or status code.

shift_path(script_name, path_info)

Return ('/a', '/b/c') -> ('b', '/a/b', 'c').

split_namespace(clark_name)

Return (namespace, localname) tuple for a property name in Clark Notation.

string_repr(s)

Return a string as hex dump.

test_if_header_dict(dav_res, if_dict, ...)

to_bytes(s[, encoding])

Convert a text string (unicode) to bytestring (str on Py2 and bytes on Py3).

to_set(val, *[, or_none, raise_error])

to_str(s[, encoding])

Convert data to native str type (bytestring on Py2 and unicode on Py3).

to_unicode_safe(s)

Convert a binary string to Unicode using UTF-8 (fallback to ISO-8859-1).

unicode_to_wsgi(u)

Convert an environment variable to a WSGI 'bytes-as-unicode' string.

update_headers_in_place(target, new_items)

Modify or append new headers to existing header list (in-place).

wsgi_to_bytes(s)

Convert a native string to a WSGI / HTTP compatible byte string.

Other Members

BASE_LOGGER_NAME

The base logger (silent by default)

HTTP_BAD_REQUEST

int([x]) -> integer int(x, base=10) -> integer

HTTP_CREATED

int([x]) -> integer int(x, base=10) -> integer

HTTP_NOT_MODIFIED

int([x]) -> integer int(x, base=10) -> integer

HTTP_NO_CONTENT

int([x]) -> integer int(x, base=10) -> integer

HTTP_OK

int([x]) -> integer int(x, base=10) -> integer

HTTP_PRECONDITION_FAILED

int([x]) -> integer int(x, base=10) -> integer

HTTP_RANGE_NOT_SATISFIABLE

int([x]) -> integer int(x, base=10) -> integer

MAX_FINITE_TIMEOUT_LIMIT

any numofsecs above the following limit is regarded as infinite

PYTHON_VERSION

Currently used Python version as string

filesystemencoding

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

public_python_info

This is reset to "Python/3" if suppress_version_info is set in the configuration.

public_wsgidav_info

Project name and version presented to the clients This is reset to "WsgiDAV" if suppress_version_info is set in the configuration.