Update location information of nodes under `oldpath`. This only affects *already loaded* nodes.
(self, oldpath: str, newpath: str)
| 3013 | return "\n".join(lines) + "\n" |
| 3014 | |
| 3015 | def _update_node_locations(self, oldpath: str, newpath: str) -> None: |
| 3016 | """Update location information of nodes under `oldpath`. |
| 3017 | |
| 3018 | This only affects *already loaded* nodes. |
| 3019 | |
| 3020 | """ |
| 3021 | oldprefix = oldpath + "/" # root node can not be renamed, anyway |
| 3022 | oldprefix_len = len(oldprefix) |
| 3023 | |
| 3024 | # Update alive and dead descendents. |
| 3025 | for cache in [self._node_manager.cache, self._node_manager.registry]: |
| 3026 | for nodepath in list(cache): |
| 3027 | if nodepath.startswith(oldprefix) and nodepath != oldprefix: |
| 3028 | nodesuffix = nodepath[oldprefix_len:] |
| 3029 | newnodepath = join_path(newpath, nodesuffix) |
| 3030 | newnodeppath = split_path(newnodepath)[0] |
| 3031 | descendent_node = self._get_node(nodepath) |
| 3032 | descendent_node._g_update_location(newnodeppath) |
| 3033 | |
| 3034 | |
| 3035 | # If a user hits ^C during a run, it is wise to gracefully close the |
no test coverage detected