|
1 | 1 | |:memo:| Modify |
2 | 2 | =================== |
3 | 3 |
|
4 | | -Shift or copy nodes within same tree or between two trees using |
5 | | -`from_paths` (list of paths) and `to_paths` (list of paths). |
| 4 | +There are two types of modification available, |
6 | 5 |
|
7 | | -There are several configurations available for more customization |
| 6 | + 1. **Non-replacing scenario**: Shift or copy nodes within same tree or between two trees using `from_paths` (list of paths) and `to_paths` (list of paths). |
| 7 | + 2. **Replacing scenario**: Shift or copy nodes within same tree or between two trees *while replacing the to-node* using `from_paths` (list of paths) and `to_paths` (list of paths). |
8 | 8 |
|
9 | | -- `skippable`: Skip shifting/copying of nodes if from_path cannot be found, defaults to False (from node must be found) |
10 | | -- `overriding`: Override existing node if it exists, defaults to False (to node must not exist) |
11 | | -- `merge_children`: Merge children and remove intermediate parent node, defaults to False (children are not merged) |
12 | | -- `merge_leaves`: Merge leaves and remove all intermediate nodes, defaults to False (leaves are not merged) |
13 | | -- `delete_children`: Shift/copy node only and delete its children, defaults to False (nodes are shifted/copied together with children) |
| 9 | +In **non-replacing scenario**, there are several configurations available for customization. |
14 | 10 |
|
15 | | -.. note:: `merge_children` and `merge_leaves` cannot be simultaneously set to `True` |
| 11 | +.. list-table:: Available Configurations for Customization |
| 12 | + :widths: 20 40 40 |
| 13 | + :header-rows: 1 |
| 14 | + |
| 15 | + * - Configuration |
| 16 | + - Description |
| 17 | + - Default Value |
| 18 | + * - `copy` |
| 19 | + - Indicates whether it is to shift the nodes, or copy the nodes |
| 20 | + - False (nodes are shifted, not copied) |
| 21 | + * - `to_tree` |
| 22 | + - Indicates whether shifting/copying is within the same tree, or between different trees |
| 23 | + - None (nodes are shifted/copied within the same tree) |
| 24 | + * - `skippable` |
| 25 | + - Skip shifting/copying of nodes if from_path cannot be found |
| 26 | + - False (from-node must be found) |
| 27 | + * - `overriding` |
| 28 | + - Override existing node if it exists |
| 29 | + - False (to-node must not exist) |
| 30 | + * - `merge_children` |
| 31 | + - Shift/copy children of from-node and remove intermediate parent node |
| 32 | + - False (children are not merged) |
| 33 | + * - `merge_leaves` |
| 34 | + - Shift/copy leaves of from-node and remove all intermediate nodes |
| 35 | + - False (leaves are not merged) |
| 36 | + * - `delete_children` |
| 37 | + - Shift/copy node only and delete its children |
| 38 | + - False (nodes are shifted/copied together with children) |
| 39 | + |
| 40 | +In **replacing scenario**, all the configurations are also available except `overriding`, `merge_children`, and `merge_leaves` as it is doing a one-to-one replacement. |
| 41 | +It is by default overriding, and there is nothing to merge. |
| 42 | + |
| 43 | +.. note:: `merge_children` and `merge_leaves` cannot be simultaneously set to `True`. |
16 | 44 |
|
17 | 45 | .. note:: Error will always be thrown if multiple from-nodes are found, paths in `from_paths` must be unique. |
18 | 46 |
|
| 47 | +Tree Modification Permutations |
| 48 | +---------------------------------- |
| 49 | + |
| 50 | +There are several ways you can mix and match the tree modification methods. |
| 51 | +If you know all the parameters to choose, feel free to use ``copy_or_shift_logic`` or ``replace_logic`` methods as they are the most customizable. |
| 52 | +All other methods calls these 2 methods directly. |
| 53 | + |
| 54 | +.. list-table:: Tree Modification Methods |
| 55 | + :widths: 10 20 10 20 |
| 56 | + :header-rows: 1 |
| 57 | + |
| 58 | + * - Shift / Copy? |
| 59 | + - Same tree / Between two trees? |
| 60 | + - Replace destination node? |
| 61 | + - Method to use |
| 62 | + * - Shift |
| 63 | + - Same tree |
| 64 | + - No |
| 65 | + - ``shift_nodes`` |
| 66 | + * - Copy |
| 67 | + - Same tree |
| 68 | + - No |
| 69 | + - ``copy_nodes`` |
| 70 | + * - Copy |
| 71 | + - Between two trees |
| 72 | + - No |
| 73 | + - ``copy_nodes_from_tree_to_tree`` |
| 74 | + * - Any |
| 75 | + - Any |
| 76 | + - No |
| 77 | + - ``copy_or_shift_logic`` |
| 78 | + * - Shift |
| 79 | + - Same tree |
| 80 | + - Yes |
| 81 | + - ``shift_and_replace_nodes`` |
| 82 | + * - Copy |
| 83 | + - Between two trees |
| 84 | + - Yes |
| 85 | + - ``copy_and_replace_nodes_from_tree_to_tree`` |
| 86 | + * - Any |
| 87 | + - Any |
| 88 | + - Yes |
| 89 | + - ``replace_logic`` |
| 90 | + |
19 | 91 | Tree Modification Illustration |
20 | 92 | ---------------------------------- |
21 | 93 |
|
|
0 commit comments