get_parent_map_chains
get dict of parent maps with chain of their children as list
Generates a dictionary of all the MaciDataObj's currently mapped parent attribute name references to its children, and returns a dict of the maps with the values represented in a chain-like structure using lists.
Useful if it is desired to view all parent attribute names with their interconnected child mappings following each other in order.
data.get_parent_map_chains() -> dict[str, list[str]] | list[str]
Basic Example getting all current parent mappings of the MaciDataObj as chains with no parameters
In this example, we simply use the get_parent_map_chains method on the MaciDataObj to get a generated dict of all the current parent attribute names with their child mappings, currently held inside the maci object, represented as a dictionary, and assign the returned data to a variable.
Example output of a basic parent map with the children following it as a chain
Parent maps have their own parent key name matching its attribute name and value being a list of attribute names starting with the parent as the first name, then children following one after another.
You may also pass in the known parent key name of the chain you wish to retrieve using the "parent_attr" optional positional parameter.
Example passing the name "attr1" in the method to receive its chain output
As mentioned in the language section Map Assignment Glyph, It is possible to have a name be a parent and a child simultaneously. This is evaluated whether a child that is following a parent also has children following it and they are all interlinked together one after another. However, if it is just a parent and not a child, it will gain its own key name with its own chain.
If a child breaks off from the chain being reassigned to a new value and has children following it, it will gain its own chain separate from the one it was linked to. In addition, if a child happens to break off from the chain by being unmapped (See unmap_attr) or deleted, the child will just be released from the chain mapping. However, if the child that broke off was unmapped or deleted and was also a parent, the next child will inherit the role of a parent if it also has children and gain its own chain.
Example output of "attr3" breaking off chain by reassignment gaining its own chain
Example output of "attr3" breaking off chain by unmap or deletion and next child gains its own chain
key-ring exception
If a chain attempts to generate with multiple children mapped to the same parent, an exception will be thrown by default stating it cannot build a chain with multiple children linked to the same parent. That behavior would describe more of a key-ring like structure over a chain. See Map Assignment Glyph for more on that. If you wish to ignore that check, use dup_link_check parameter to disable it, but your chains may break off into separate chains if encountered as explained above.
For more information on the mapping concept, see Map Assignment Glyph in the language section and map_attr.
partner methods
Methods that provide related utility to this method
map_attr -> Map an attribute name unmap_attr -> Unmap an attribute name
parameters & arguments
Describes all parameter functionality and accepted data types
Last updated