Set location-dependent attributes. Sets the location-dependent attributes of this node to reflect that it is placed under the specified `parentnode`, with the specified `name`. This also triggers the insertion of file references to this node. If the maximum
(self, parentnode: Group, name: str)
| 347 | assert self._v_file.isopen, "found an open node in a closed file" |
| 348 | |
| 349 | def _g_set_location(self, parentnode: Group, name: str) -> None: |
| 350 | """Set location-dependent attributes. |
| 351 | |
| 352 | Sets the location-dependent attributes of this node to reflect |
| 353 | that it is placed under the specified `parentnode`, with the |
| 354 | specified `name`. |
| 355 | |
| 356 | This also triggers the insertion of file references to this |
| 357 | node. If the maximum recommended tree depth is exceeded, a |
| 358 | `PerformanceWarning` is issued. |
| 359 | |
| 360 | """ |
| 361 | file_ = parentnode._v_file |
| 362 | parentdepth = parentnode._v_depth |
| 363 | |
| 364 | self._v_file = file_ |
| 365 | self._v_isopen = True |
| 366 | |
| 367 | root_uep = file_.root_uep |
| 368 | if name.startswith(root_uep): |
| 369 | # This has been called from File._get_node() |
| 370 | assert parentdepth == 0 |
| 371 | if root_uep == "/": |
| 372 | self._v_pathname = name |
| 373 | else: |
| 374 | self._v_pathname = name[len(root_uep) :] |
| 375 | _, self._v_name = split_path(name) |
| 376 | self._v_depth = name.count("/") - root_uep.count("/") + 1 |
| 377 | else: |
| 378 | # If we enter here is because this has been called elsewhere |
| 379 | self._v_name = name |
| 380 | self._v_pathname = join_path(parentnode._v_pathname, name) |
| 381 | self._v_depth = parentdepth + 1 |
| 382 | |
| 383 | # Check if the node is too deep in the tree. |
| 384 | if parentdepth >= self._v_maxtreedepth: |
| 385 | warnings.warn( |
| 386 | """\ |
| 387 | node ``%s`` is exceeding the recommended maximum depth (%d);\ |
| 388 | be ready to see PyTables asking for *lots* of memory and possibly slow I/O""" |
| 389 | % (self._v_pathname, self._v_maxtreedepth), |
| 390 | PerformanceWarning, |
| 391 | ) |
| 392 | |
| 393 | if self._v_pathname != "/": |
| 394 | file_._node_manager.cache_node(self, self._v_pathname) |
| 395 | |
| 396 | def _g_update_location(self, newparentpath: str) -> None: |
| 397 | """Update location-dependent attributes. |
no test coverage detected