[Yum-devel] standardize on a package object?

seth vidal skvidal at linux.duke.edu
Mon Aug 21 12:30:04 UTC 2006


On Mon, 2006-08-21 at 07:25 -0400, Paul Nasrat wrote:
> On Sun, 2006-08-20 at 17:46 -0400, seth vidal wrote:
> > Okay,
> >  At this point we have a package object representation available for
> > everything. Now the question becomes do we want to start writing methods
> > and converting all of our utility functions to take package objects.
> > 
> > We frequently do something like:
> > 
> > (n1,a1,e1,v1,r1) = pkg.pkgtup
> > (n2,a2,e2,v2,r2) = instpkg.pkgtup
> > rc = rpmUtils.miscutils.compareEVR((e, v, r), (te, tv, tr))
> > ....
> > 
> > would it make sense for us to have a compareEVR that took package
> > objects?
> 
> Shouldn't we just make the objects comparable by rich comparison
> methods?
> 
> __lt__(
> self, other)
> __le__(
> self, other)
> __eq__(
> self, other)
> __ne__(
> self, other)
> __gt__(
> self, other)
> __ge__(
> self, other
> 
> Alternatively we could use an approach similar to that in sets.Sets
> 

Except that it's not quite that simple, for most of the objects.

b/c we need to compare different things.

sometimes were comparing "which one of these versions is newer"

and sometimes were comparing "which one of these packages is 'better'"

ie: which arch is better for this situation
    which package name is shorter (sigh)

So I'm not sure how we could fairly use the rich comparison methods for
all of these multiple comparisons.

my only thought is that we create a subobject for the version inside a
package object so we could do:

 if po.ver > otherpo.ver:
    ....

I'm not sure if that's more or less messy, honestly.

-sv





More information about the Yum-devel mailing list