spawn.util

Utility classes and functions used by spawn

class spawn.util.ArrayProperty(type_, fget=None, fset=None, fdel=None, fvalidate=None, default=None, doc=None, abstract=False, readonly=False)[source]

Implementation of PropertyBase for array properties __get__(), __set__() and __delete__() return array wrappers that allow indexes to be used

class spawn.util.FloatProperty(fget=None, fset=None, fdel=None, fvalidate=None, default=None, doc=None, abstract=False, readonly=False, min=None, max=None)[source]

Implementation of NumericProperty for float properties

class spawn.util.IntProperty(fget=None, fset=None, fdel=None, fvalidate=None, default=None, doc=None, abstract=False, readonly=False, min=None, max=None)[source]

Implementation of NumericProperty for int properties

class spawn.util.PathBuilder(path='')[source]

The path builder class

This class provides a standardised way to build paths and interpolate/format them with values

format(properties, indices=None)[source]

Format the path by interpolating with the properties provided.

If indices are provided, use them in place of the properties.

Parameters
  • properties (dict) – The properties to interpolate with.

  • indices – The indicies to use in place of the properties, if any. Defaults to None.

Returns

A new instance with the interpolated values

Return type

PathBuilder

static index(index, index_format='1')[source]

Formats an index given the index_format provided

Parameters
  • index (int) – The index to format

  • index_format (str) – The index format (see below for examples).

Returns

The formatted index

Return type

str

Format

Description

Examples

0*[d]+

Padded integer with start value

01 -> 01, 02, 03… 002 -> 002, 003, 004…

[a]+

Alphabetical

a -> a, b, c, d… aa -> aa, ab, ac, ad…

join(other)[source]

Join two paths by adding other onto the end of self

Parameters

other (str) – The path to add to the end of this path

Returns

A new path builder with the joined paths

Return type

PathBuilder

join_start(other)[source]

Join two paths by adding other onto the start of self

Parameters

other (str) – The path to add to the start of this path

Returns

A new path builder with the joined paths

Return type

PathBuilder

class spawn.util.StringProperty(fget=None, fset=None, fdel=None, fvalidate=None, default=None, doc=None, abstract=False, readonly=False, possible_values=None, regex=None)[source]

Implementation of TypedProperty for string properties

class spawn.util.TypedProperty(type_, fget=None, fset=None, fdel=None, fvalidate=None, default=None, doc=None, abstract=False, readonly=False)[source]

Base class for typed properties

spawn.util.configure_logging(log_level, command_name, log_console=True, log_file=True)[source]

Configure logging

Parameters
  • log_level (str) – The log level (error, warning, info, debug, trace)

  • command_name (str) – The name of the invoked subcommand

  • log_console (bool) – True if logs should be displayed in the console; otherwise False. Defaults to True.

  • log_file (bool) – True if logs should be written to file; otherwise False. Defaults to True.

spawn.util.float_property(fget)[source]

Function decorator for FloatProperty

spawn.util.int_property(fget)[source]

Function decorator for IntProperty

spawn.util.prettyspec(spec, outstream=None)[source]

Writes the given spec tree to the stream provided

spawn.util.quote(strpath)[source]

Wrap the given string in quotes

Parameters

strpath (str) – A string representing a path

spawn.util.string_property(fget)[source]

Function decorator for StringProperty

spawn.util.typed_property(type_)[source]

Function decorator for TypedProperty