Hello

I am not able to rename a node which has parent nodes. The doc doesn't specify 
any restriction to the usage of the renameNode method.
Here is a small example script to show what I want to achieve :

import tables

# Create file and groups
file = tables.openFile("test.hdf5", "w")
file.createGroup("/", "data", "Data")
file.createGroup("/data", "id", "Single Data")
file.createGroup("/data/id/", "curves1", "Curve 1")
file.createGroup("/data/id/", "curves2", "Curve 2")

# Rename (works)
file.renameNode("/data/id/curves1", "newcurve1")

# Rename (doesn't work)
file.renameNode("/data/id", "newid")

The first rename will work and rename "/data/id/curves1" to "/data/id/newcurve1"
The second rename will fail with the following traceback :

Traceback (most recent call last):
  File "Rename.py", line 14, in <module>
    file.renameNode("/data/id", "newid")
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tables/file.py",
 line 1157, in renameNode
    obj._f_rename(newname, overwrite)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tables/node.py",
 line 590, in _f_rename
    self._f_move(newname=newname, overwrite=overwrite)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tables/node.py",
 line 674, in _f_move
    self._g_move(newparent, newname)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tables/group.py",
 line 565, in _g_move
    self._v_file._updateNodeLocations(oldPath, newPath)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tables/file.py",
 line 2368, in _updateNodeLocations
    descendentNode._g_updateLocation(newNodePPath)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tables/node.py",
 line 414, in _g_updateLocation
    file_._refNode(self, newPath)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tables/file.py",
 line 2287, in _refNode
    "file already has a node with path ``%s``" % nodePath
AssertionError: file already has a node with path ``/data``
Closing remaining open files: test.hdf5... done
Exception AttributeError: "'File' object has no attribute '_aliveNodes'" in  
ignored

Perhaps I can not do what I want to do here, or is there another method I 
should use ?

Thanks in advance

Michka Popoff
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to