Andreas Hilboll wrote:
> I'm using Pytables 2.1 and always getting NaturalNameWarnings when 
> creating the group structure in my files. This is quite annoying, 
> because I'm creating *many* of these groups and thus these warnings spam 
> me and make me oversee the screen output which would be interesting to me.
> How can I get rid of these warnings?
> And no, changing my groups' names so that the warnings disappear are 
> (unfortunately) not an option ...

        They're normal Python warnings, so you can suppress them the usual way. 
  Use the python warnings module.

        I've done this for setting attributes.  The code was somewhat the 
below.  (Just sketching this in the e-mail.  Forgive any obvious errors.)

import warnings
import tables

def write_unsafe_attrs(node, attrs) :
   original_warnings = list(warnings.filters)
   warnings.simplefilter('ignore', tables.NaturalNameWarning)
   for name, value in attrs:
     node._f_setAttr(name, value)
   warnings.filters = original_warnings


In 2.6, there's a context manager to take care of the resetting of the 
warning filters after you leave scope.

-- 
Anthony Foglia
Princeton Consultants
(609) 987-8787 x233


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to