bgdev.utils.side¶
Module to deal with sided data.
- created
02/07/2018
- author
Benoit Gielly <benoit.gielly@gmail.com>
-
convert_side
(data, sides='LR', both=False)[source]¶ Replace recursively all iterations of {} with side in a data structure.
- Parameters
data (list or dict) – The data to traverse and update.
sides (str) – The sides to replace brackets with.
both (bool) – By default, if the key is “sided”, the values associated will only get the same side as the key. Otherwise, values will get both sides. Default is False.
Example
data = side.convert_side({ "spine_01_grp": "spine_01_jnt", "{}_shoulder_mechanic_grp": "{}_arm_shoulder_jnt", "{}_knee_pistons_grp": "{}_leg_knee_jnt", }) >>> # Result: {"L_knee_pistons_grp": "L_leg_knee_jnt", "L_shoulder_mechanic_grp": "L_arm_shoulder_jnt", "R_knee_pistons_grp": "R_leg_knee_jnt", "R_shoulder_mechanic_grp": "R_arm_shoulder_jnt", "spine_01_grp": "spine_01_jnt"} #
- Returns
An updated and sided copy of the given data.
- Return type
dict or list