(
nodepaths: list[str], get_node: Callable[[str], Group | Node]
)
| 518 | |
| 519 | @staticmethod |
| 520 | def _close_nodes( |
| 521 | nodepaths: list[str], get_node: Callable[[str], Group | Node] |
| 522 | ) -> None: |
| 523 | for nodepath in nodepaths: |
| 524 | try: |
| 525 | node = get_node(nodepath) |
| 526 | except KeyError: |
| 527 | pass |
| 528 | else: |
| 529 | if not node._v_isopen or node._v__deleting: |
| 530 | continue |
| 531 | |
| 532 | try: |
| 533 | # Avoid descendent nodes to also iterate over |
| 534 | # their descendents, which are already to be |
| 535 | # closed by this loop. |
| 536 | if hasattr(node, "_f_get_child"): |
| 537 | node._g_close() |
| 538 | else: |
| 539 | node._f_close() |
| 540 | del node |
| 541 | except ClosedNodeError: |
| 542 | # import traceback |
| 543 | # type_, value, tb = sys.exc_info() |
| 544 | # exception_dump = ''.join( |
| 545 | # traceback.format_exception(type_, value, tb)) |
| 546 | # warnings.warn( |
| 547 | # "A '%s' exception occurred trying to close a node " |
| 548 | # "that was supposed to be open.\n" |
| 549 | # "%s" % (type_.__name__, exception_dump)) |
| 550 | pass |
| 551 | |
| 552 | def close_subtree(self, prefix: str = "/") -> None: |
| 553 | """Close a sub-tree of nodes.""" |
no test coverage detected