From: Karol L. <kar...@kn...> - 2007-04-26 11:23:26
|
On Thursday 26 April 2007 12:57, Noel O'Boyle wrote: > On 26/04/07, Karol Langner <kar...@kn...> wrote: > > On Thursday 26 April 2007 08:04, Noel wrote: > > > Do any of our parsers set the attribute, but then delattr it? Might be > > > worth checking. Also, it would be possible to check the types of > > > attributes at this point, using an assert statement. I can look into > > > this. > > > > langner@slim:~/tmp/python/cclib/trunk/src/cclib/parser$ grep "delattr" * > > logfileparser.py: delattr(self, attr) > > > > The actual parsing no - the only place it is used is in LogFile.clean(). > > > > What do you mean by "checking the types of attributes at this point"? Do > > you mean checking that the value is the correct type inside > > LogFile.__setattr()? > > E.g. verify that mocoeffs is a list of 1 or 2 numeric arrays of rank 2 > or whatever. It wouldn't add much overhead to the program, and would > act as a sanity check. As you know, presently types are checked after parsing (I added the _attrtypes list today). This could be done additionally in __setattr__. Checking the contents of lists, though, is done only for lists that are supposed to contain arrays. The method __setattr__, however, is called only when a new value is assigned (using equivalence or whatever). So that would be a rather weak sanity check for list contents - if something is appended to the list, or one of the elements changed, the method is not called. - Karol -- written by Karol Langner Thu Apr 26 15:11:57 CEST 2007 |