yawning_titan.config.groups.core.ActionLikelihoodGroup#
- class yawning_titan.config.groups.core.ActionLikelihoodGroup(doc=None, use=False, likelihood=None)[source]#
Bases:
ConfigGroup
Group to represent an action, likelihood common config group.
The ActionLikelihoodGroup constructor.
- Parameters:
use – Whether to use the action or not.
likelihood – The likelihood of the action.
doc – An optional descriptor.
Methods
Get the attributes of the class that are either :class: ConfigGroup or
ConfigItem
.Get all attributes of the class that are not :class: ConfigGroup or :class: ConfigItem.
Set the values of all :class: ConfigGroup or
ConfigItem
elements.Set the elements of the group from a .yaml file.
Represent the class as a string.
Return the ConfigGroup as a dict.
Convert the group into a unitary depth dictionary of legacy config value (aliases) to :class: ConfigItem's.
Save the values of the elements of the group to a .yaml file.
Validate the ActionLikelihoodGroup.
Call the .validate() method on each of the elements in the group.
Attributes
~yawning_titan.config.core.ConfigGroup children of the group.
~yawning_titan.config.core.ConfigItem children of the group.
- validate()[source]#
Validate the ActionLikelihoodGroup.
- This is done at two levels:
1. A group level validation is performed that checks if likelihood and chance are provided when use is True. 2. An item level validation is performed by calling .validate on the use and likelihood config items.
- Returns:
An instance of ConfigGroupValidation.
- 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.
- set_from_dict(config_dict, legacy=False, infer_legacy=False, **kwargs)#
Set the values of all :class: ConfigGroup or
ConfigItem
elements.- Parameters:
config_dict – A dictionary representing values of all config elements.
legacy – Whether to use the alias names for config elements to construct the config from a legacy dictionary.
infer_legacy – Attempt to recognise if a config is of a legacy type.
- kwargs can contain 2 parameters:
- root: Whether the element is a base level element or not.
if the element is a root then it should validate all of its descendants.
legacy_lookup: The current flattened dictionary representation of the class by its legacy keys.
- set_from_yaml(file_path, legacy=False, infer_legacy=False)#
Set the elements of the group from a .yaml file.
- Parameters:
file_path – The path to the .yaml file.
legacy – Whether to use the alias names for config elements to construct the config from a legacy dictionary.
infer_legacy – Attempt to recognise if a config is of a legacy type.
- stringify()#
Represent the class as a string.
- Returns:
A string.
- to_dict(values_only=False, legacy=False, include_none=True)#
Return the ConfigGroup as a dict.
- Parameters:
values_only – Create a dictionary containing only the value of :class: ConfigItem’s
legacy – Convert the group into a unitary depth dictionary of legacy config value (aliases) to :class: ConfigItem’s by calling :method: ConfigGroup.to_legacy.
- Returns:
The ConfigGroup as a dict.
- to_legacy_dict(flattened_dict=None)#
Convert the group into a unitary depth dictionary of legacy config value (aliases) to :class: ConfigItem’s.
- Returns:
a dictionary
- to_yaml(file_path)#
Save the values of the elements of the group to a .yaml file.
- Parameters:
file_path – The path to the .yaml file
- validate_elements()#
Call the .validate() method on each of the elements in the group.