From: Karol L. <kar...@kn...> - 2007-02-02 18:39:11
|
I have a more radical idea for refactoring the code for the parsers, which could structure them better and make them more 'standardized'. It still won't change anything in the user-side, but I really think something like this will give alot of long-term benifits in terms of writing new parsers and regulating common aspects (like LogFile.progress and attribute types). The attached file contains my fast scetch of the new parse function (so it probaly won't work). Besides parse() itself: 1) the extract methods of all parsers would be revised. This is pretty straightforward and I would do it with a script - the loop is cut out, and each conditional block for line content needs to returns a tuple with the attributes that were set. If the "_" prefix were to denote private attributes, extract should probably be renamed to _extract at this point. 2) a few new dictionaries are needed for common information, as used in the attached file: _attrtypes (attribute types we want for each attribute), _fupdate (for the progress update), _msg (messages for progress). The last two should logically be attributes of the progress object itself), and could be set to default values by cclib if they don't exist (for compatibility). And that would be about it! If this all looks like it might work :) and you think it's a good idea, I'll go straight ahead and work on the details. I don't think it would take alot of work, and I have some spare time this weekend. Karol -- written by Karol Langner Fri Feb 2 19:00:35 CET 2007 |