El dc 22 de 11 del 2006 a les 17:04 +0100, en/na Berthold Höllmann va
escriure:
> Describing the Files class, page 55 of the PyTables 1.3.3 manual says:
> 
> trMap -- A dictionary that maps node names between PyTables and HDF5
>    domain names. Its initial values are set from the trMap parameter
>    passed to the openFile function. You can change its contents after
>    a file is opened and the new map will take effect over any new
>    object added to the tree.
> 
> 
> I have the following test case which does not work for the second try:
> 
> import tables
> def test(f):
>     print f.listNodes('/Xbsxffe_info/X0')
>     p = f.getNode('/Xbsxffe_info/X0/Xversion_id')
>     print p.read()
> 
> map = {'Xbsxffe_info': 'bsxffe_info', 'X0': '0', 'Xversion_id': 'version_id'}
> fp1 = 
> tables.openFile('/data/tmp/hoel/GLPy_numpy_conversion/test/data/motor.bmh', 
> mode='r',
>                      trMap=map)
> test(fp1)
> fp1.close()
> fp2 = 
> tables.openFile('/data/tmp/hoel/GLPy_numpy_conversion/test/data/motor.bmh', 
> mode='r',
>                      trMap={})
> fp2.trMap = fp2.trMap.update(map)
> test(fp2)
> fp2.close()
> 
> I get:
> ...
> Traceback (most recent call last):
>   File "tables_test2.py", line 15, in <module>
>     test(fp2)
>   File "tables_test2.py", line 3, in test
>     print f.listNodes('/Xbsxffe_info/X0')
>   File 
> "/usr/local/gltools/python/Python-2.5/linux/lib/python2.5/site-packages/tables/File.py",
>  line 1208, in listNodes
>     group = self.getNode(where)  # Does the parent exist?
>   File 
> "/usr/local/gltools/python/Python-2.5/linux/lib/python2.5/site-packages/tables/File.py",
>  line 952, in getNode
>     node = self._getNode(nodePath)
>   File 
> "/usr/local/gltools/python/Python-2.5/linux/lib/python2.5/site-packages/tables/File.py",
>  line 898, in _getNode
>     node = parentNode._g_loadChild(childName)
>   File 
> "/usr/local/gltools/python/Python-2.5/linux/lib/python2.5/site-packages/tables/Group.py",
>  line 365, in _g_loadChild
>     self._g_checkHasChild(childName)
>   File 
> "/usr/local/gltools/python/Python-2.5/linux/lib/python2.5/site-packages/tables/Group.py",
>  line 353, in _g_checkHasChild
>     % (self._v_pathname, childName))
> tables.exceptions.NoSuchNodeError: group ``/`` does not have a child named 
> ``Xbsxffe_info``
> Closing remaining opened files...  
> /data/tmp/hoel/GLPy_numpy_conversion/test/data/motor.bmh... done.
> 
> So, how do I successfully change the content of the trMap?

Yep, I can reproduce this. I think we introduced this problem back in
PyTables 1.2, when the cache of nodes was set in place. Sorry, but it
seems that modifying the trMap when you have already opened the file is
not possible anymore, and solving this would be a major task for us.
Now that you have the possibility to use File.getNode(), do you still
need this capability?

Any other people is using the trMap trick besides Berthold and wants to
see this capability being maintained?  I'm asking this because now that
Berthold brought this my attention, it seems an ugly hack to my eyes, so
it might well be a candidate to disappear for PyTables 2.0.

Regards,

-- 
Francesc Altet    |  Be careful about using the following code --
Carabos Coop. V.  |  I've only proven that it works, 
www.carabos.com   |  I haven't tested it. -- Donald Knuth


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to