Navigation

  • index
  • modules    
  • modules    
  • next    
  • previous    
  • PyTables 3.0.0rc2 documentation »
  • PyTables User’s Guide »
  • Library Reference »

Link classes¶

The Link class¶

class tables.link.Link(parentnode, name, target=None, _log=False)[source]¶

Abstract base class for all PyTables links.

A link is a node that refers to another node. The Link class inherits from Node class and the links that inherits from Link are SoftLink and ExternalLink. There is not a HardLink subclass because hard links behave like a regular Group or Leaf. Contrarily to other nodes, links cannot have HDF5 attributes. This is an HDF5 library limitation that might be solved in future releases.

See Using links for more convenient access to nodes for a small tutorial on how to work with links.

Link attributes

target¶

The path string to the pointed node.

Link instance variables¶

Link._v_attrs[source]¶

A NoAttrs instance replacing the typical AttributeSet instance of other node objects. The purpose of NoAttrs is to make clear that HDF5 attributes are not supported in link nodes.

Link methods¶

The following methods are useful for copying, moving, renaming and removing links.

Link.copy(newparent=None, newname=None, overwrite=False, createparents=False)[source]¶

Copy this link and return the new one.

See Node._f_copy() for a complete explanation of the arguments. Please note that there is no recursive flag since links do not have child nodes.

Link.move(newparent=None, newname=None, overwrite=False)[source]¶

Move or rename this link.

See Node._f_move() for a complete explanation of the arguments.

Link.remove()[source]¶

Remove this link from the hierarchy.

Link.rename(newname=None, overwrite=False)[source]¶

Rename this link in place.

See Node._f_rename() for a complete explanation of the arguments.

The SoftLink class¶

class tables.link.SoftLink(parentnode, name, target=None, _log=False)[source]¶

Represents a soft link (aka symbolic link).

A soft link is a reference to another node in the same file hierarchy. Getting access to the pointed node (this action is called dereferrencing) is done via the __call__ special method (see below).

SoftLink special methods¶

The following methods are specific for dereferrencing and representing soft links.

SoftLink.__call__()[source]¶

Dereference self.target and return the object.

Examples

>>> f=tables.open_file('data/test.h5')
>>> print f.root.link0
/link0 (SoftLink) -> /another/path
>>> print f.root.link0()
/another/path (Group) ''
SoftLink.__str__()[source]¶

Return a short string representation of the link.

Examples

>>> f=tables.open_file('data/test.h5')
>>> print f.root.link0
/link0 (SoftLink) -> /path/to/node

The ExternalLink class¶

class tables.link.ExternalLink(parentnode, name, target=None, _log=False)[source]¶

Represents an external link.

An external link is a reference to a node in another file. Getting access to the pointed node (this action is called dereferencing) is done via the __call__() special method (see below).

ExternalLink attributes

extfile¶

The external file handler, if the link has been dereferenced. In case the link has not been dereferenced yet, its value is None.

ExternalLink methods¶

ExternalLink.umount()[source]¶

Safely unmount self.extfile, if opened.

ExternalLink special methods¶

The following methods are specific for dereferrencing and representing external links.

ExternalLink.__call__(**kwargs)[source]¶

Dereference self.target and return the object.

You can pass all the arguments supported by the open_file() function (except filename, of course) so as to open the referenced external file.

Examples

>>> f=tables.open_file('data1/test1.h5')
>>> print f.root.link2
/link2 (ExternalLink) -> data2/test2.h5:/path/to/node
>>> plink2 = f.root.link2('a')  # open in 'a'ppend mode
>>> print plink2
/path/to/node (Group) ''
>>> print plink2._v_filename
'data2/test2.h5'        # belongs to referenced file
ExternalLink.__str__()[source]¶

Return a short string representation of the link.

Examples

>>> f=tables.open_file('data1/test1.h5')
>>> print f.root.link2
/link2 (ExternalLink) -> data2/test2.h5:/path/to/node

Logo

Table Of Contents

  • Link classes
    • The Link class
      • Link instance variables
      • Link methods
    • The SoftLink class
      • SoftLink special methods
    • The ExternalLink class
      • ExternalLink methods
      • ExternalLink special methods

Previous topic

Homogenous storage classes

Next topic

Declarative classes

This Page

  • Show Source

Quick search

Enter search terms or a module, class or function name.

Navigation

  • index
  • modules    
  • modules    
  • next    
  • previous    
  • PyTables 3.0.0rc2 documentation »
  • PyTables User’s Guide »
  • Library Reference »
© Copyright 2011-2013, PyTables maintainers. Created using Sphinx 1.1.3.