wuttjamaican.util

WuttJamaican - utilities

wuttjamaican.util.load_entry_points(group, ignore_errors=False)[source]

Load a set of setuptools-style entry points.

This is used to locate “plugins” and similar things, e.g. the set of subcommands which belong to a main command.

Parameters:
  • group – The group (string name) of entry points to be loaded, e.g. 'wutta.commands'.

  • ignore_errors – If false (the default), any errors will be raised normally. If true, errors will be logged but not raised.

Returns:

A dictionary whose keys are the entry point names, and values are the loaded entry points.

wuttjamaican.util.load_object(spec)[source]

Load an arbitrary object from a module, according to the spec.

The spec string should contain a dotted path to an importable module, followed by a colon (':'), followed by the name of the object to be loaded. For example:

wuttjamaican.util:parse_bool

You’ll notice from this example that “object” in this context refers to any valid Python object, i.e. not necessarily a class instance. The name may refer to a class, function, variable etc. Once the module is imported, the getattr() function is used to obtain a reference to the named object; therefore anything supported by that approach should work.

Parameters:

spec – Spec string.

Returns:

The specified object.

wuttjamaican.util.parse_bool(value)[source]

Derive a boolean from the given string value.

wuttjamaican.util.parse_list(value)[source]

Parse a configuration value, splitting by whitespace and/or commas and taking quoting into account etc., yielding a list of strings.