dolor.util.misc

Miscellaneous utilities.

get_subclasses(*args)[source]

Gets the subclasses of the parameters.

Parameters

*args (type) – The types to get the subclasses of.

Returns

The subclasses of *args.

Return type

set

default(value, default)[source]

Defaults a variable.

Parameters
  • value – The value to potentially default.

  • default – The default value.

Returns

If value is None, then default is returned, else value is returned.

Return type

any

arg_annotations(func, *args, **kwargs)[source]

Maps function arguments to their annotations.

Parameters
  • func (function) – The function to take annotations from.

  • *args – The arguments to map annotations to.

  • **kwargs – The arguments to map annotations to.

Returns

  • args_annotations (list) – The annotations for *args, of the form [(value, annotation)].

  • kwargs_annotations (dict) – The annotations for *args, of the form {name: (value, annotation)}.

class ZlibDecompressFile(f, *args, **kwargs)[source]

Bases: io.IOBase

A simple read-only file object for decompressing zlib data.

Parameters
  • f – The file object to wrap.

  • *args – Forwarded to zlib.decompressobj().

  • **kwargs – Forwarded to zlib.decompressobj().

read(size=- 1)[source]

Reads decompressed data from the wraped file object.

Parameters

size (int) – The amount of data to return. If -1, decompress all the data that’s left.

Returns

The decompressed data.

Return type

bytes

close()[source]

Closes the wrapped file object.