yawning_titan.config.core.ConfigGroupValidation#

class yawning_titan.config.core.ConfigGroupValidation(fail_reasons=None, fail_exceptions=None)[source]#

Bases: ConfigValidationBase

Used to return a validation result for a group of dependant config items, and the list of item validations.

If validation fails, a reason why and any exception raised are returned.

Methods

add_element_validation

Add a ConfigItemValidation or ConfigGroupValidation to the item validation dict.

add_validation

Add a validation fail_reason, exception pair to their respective lists.

get_config_elements

Get the attributes of the class that are either :class: ConfigGroup or ConfigItem.

get_non_config_elements

Get all attributes of the class that are not :class: ConfigGroup or :class: ConfigItem.

log

Return the validation results as a formatted string.

stringify

Represent the class as a string.

to_dict

Express the error tree as a dictionary.

Attributes

config_groups

~yawning_titan.config.core.ConfigGroup children of the group.

config_items

~yawning_titan.config.core.ConfigItem children of the group.

element_validation

The dict of element to ConfigItemValidation and ConfigGroupValidation validations.

elements_passed

Returns True if all items passed validation, otherwise returns False.

group_passed

fail_reasons or :attribute: fail_exceptions.

passed

fail_reasons or :attribute: fail_exceptions and the group passed.

add_element_validation(element_name, validation)[source]#

Add a ConfigItemValidation or ConfigGroupValidation to the item validation dict.

Parameters:
  • element_name – The name of the element.

  • validation – the instance of ConfigItemValidation.

to_dict(element_name='root', root=True)[source]#

Express the error tree as a dictionary.

Parameters:

element_name – A string name for the element to be represented.

Returns:

A dict of element names to validation errors or validation dictionaries.

log(element_name='root')[source]#

Return the validation results as a formatted string.

Parameters:

element_name – A string name for the element to be represented.

property passed#

fail_reasons or :attribute: fail_exceptions and the group passed.

The group validation has passed and all element validation has passed.

Returns:

A bool.

Type:

Returns True if there are no

Type:

attribute

property group_passed#

fail_reasons or :attribute: fail_exceptions.

Returns:

A bool.

Type:

Returns True if there are no

Type:

attribute

property element_validation#

The dict of element to ConfigItemValidation and ConfigGroupValidation validations.

Returns:

A dict.

property elements_passed#

Returns True if all items passed validation, otherwise returns False.

Returns:

A bool.

add_validation(fail_reason, exception)#

Add a validation fail_reason, exception pair to their respective lists.

Additionally check that no such error already exists.

Parameters:
  • fail_reason – A string message to describe a particular error.

  • exception – A wrapped Exception object that can be used to raise an error for the fail_reason.

property config_groups#

~yawning_titan.config.core.ConfigGroup children of the group.

Type:

Property to represent the

Type:

class

property config_items#

~yawning_titan.config.core.ConfigItem children of the group.

Type:

Property to represent the

Type:

class

get_config_elements(types=None)#

Get the attributes of the class that are either :class: ConfigGroup or ConfigItem.

Parameters:

_type – An optional type for a specific type of config element.

Returns:

A dictionary of names to config elements.

get_non_config_elements()#

Get all attributes of the class that are not :class: ConfigGroup or :class: ConfigItem.

Returns:

A dictionary of names to attributes.

stringify()#

Represent the class as a string.

Returns:

A string.