GNOME Bugzilla – Bug 654582
Clean up module XML parsing
Last modified: 2013-05-18 15:02:11 UTC
The main motivation is to avoid having to change all 6 module types when I want to add a new XML node to Package.
Created attachment 191929 [details] [review] Move "branch" attribute into Package, consistently order constructor arguments All current subclasses of Package have a "branch" attribute, so move it in there. While we're doing this, clean up all subclasses so that they consistently pass "branch, dependencies, after, suggests". Then after that their own arguments. The motivation for this is preparatory cleanup for a larger code cleanup patch.
Created attachment 191930 [details] [review] Move some XML parsing for Package into base class All module types repeatedly parsed the common attributes like 'id', and while they shared a function to parse things like dependencies and branch, it was still a copied line of code. Also, all module types had to have two copies of the default values of their attributes (like 'autogen.sh' for autogen_sh of AutogenModule) due to the way the constructors were invoked. Clean this up by moving the XML parsing for the common bits into the Package class. Then each module type explicitly only cares about the attributes it adds. The diff speaks for itself; compare e.g. waf.py before and after. Note - autotools needed a bigger refactoring due to things like the $prefix substitutions and changing the default for 'autogen-sh' based on whether or not the branch is a tarball.
Created attachment 191982 [details] [review] Move some XML parsing for Package into base class This version combines the previous two patches, and also moves us farther towards getting rid of the keyword argument duplication, which is necessary to avoid having to touch all modules when we want to change Package.
Attachment 191982 [details] pushed as fc61d74 - Move some XML parsing for Package into base class
Review of attachment 191982 [details] [review]: note that these lines of autotools.py are never executed: 359 elif isinstance(instance.branch, TarballBranch): 360 # in tarballs, force autogen-sh to be configure, unless autogen-sh is 361 # already set 362 instance.autogen_sh = 'configure' it would work fine if indented one level to the left. (i think "if autogen_sh is not None" is not needed at all)