After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 654582 - Clean up module XML parsing
Clean up module XML parsing
Status: RESOLVED FIXED
Product: jhbuild
Classification: Infrastructure
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Jhbuild maintainers
Jhbuild QA
Depends on:
Blocks: 564373
 
 
Reported: 2011-07-13 23:56 UTC by Colin Walters
Modified: 2013-05-18 15:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Move "branch" attribute into Package, consistently order constructor arguments (10.03 KB, patch)
2011-07-13 23:56 UTC, Colin Walters
none Details | Review
Move some XML parsing for Package into base class (15.18 KB, patch)
2011-07-13 23:56 UTC, Colin Walters
none Details | Review
Move some XML parsing for Package into base class (21.37 KB, patch)
2011-07-14 16:10 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2011-07-13 23:56:24 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.
Comment 1 Colin Walters 2011-07-13 23:56:26 UTC
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.
Comment 2 Colin Walters 2011-07-13 23:56:30 UTC
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.
Comment 3 Colin Walters 2011-07-14 16:10:21 UTC
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.
Comment 4 Colin Walters 2011-07-15 20:51:44 UTC
Attachment 191982 [details] pushed as fc61d74 - Move some XML parsing for Package into base class
Comment 5 Marcin Wojdyr 2013-05-18 15:02:11 UTC
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)