Dereference self.target and return the object. You can pass all the arguments supported by the :func:`open_file` function (except filename, of course) so as to open the referenced external file. Examples -------- :: >>> f = tb.open_file(
(self, **kwargs)
| 395 | return filename, "/" + target |
| 396 | |
| 397 | def __call__(self, **kwargs) -> Node: |
| 398 | """Dereference self.target and return the object. |
| 399 | |
| 400 | You can pass all the arguments supported by the :func:`open_file` |
| 401 | function (except filename, of course) so as to open the referenced |
| 402 | external file. |
| 403 | |
| 404 | Examples |
| 405 | -------- |
| 406 | :: |
| 407 | |
| 408 | >>> f = tb.open_file('tables/tests/elink.h5') |
| 409 | >>> f.root.pep.pep2 |
| 410 | /pep/pep2 (ExternalLink) -> elink2.h5:/pep |
| 411 | >>> pep2 = f.root.pep.pep2(mode='r') # open in 'r'ead mode |
| 412 | >>> print(pep2) |
| 413 | /pep (Group) '' |
| 414 | >>> pep2._v_file.filename # belongs to referenced file |
| 415 | 'tables/tests/elink2.h5' |
| 416 | >>> f.close() |
| 417 | |
| 418 | """ |
| 419 | filename, target = self._get_filename_node() |
| 420 | |
| 421 | if not Path(filename).is_absolute(): |
| 422 | # Resolve the external link with respect to this |
| 423 | # file's directory. See #306. |
| 424 | filename = str(Path(self._v_file.filename).parent / filename) |
| 425 | |
| 426 | if self.extfile is None or not self.extfile.isopen: |
| 427 | self.extfile = tb.open_file(filename, **kwargs) |
| 428 | else: |
| 429 | # XXX: implement better consistency checks |
| 430 | assert self.extfile.filename == filename |
| 431 | assert self.extfile.mode == kwargs.get("mode", "r") |
| 432 | |
| 433 | return self.extfile._get_node(target) |
| 434 | |
| 435 | def umount(self) -> None: |
| 436 | """Safely unmount self.extfile, if opened.""" |
nothing calls this directly
no test coverage detected