[Yum-devel] Re: [Yum] Scripting Yum

seth vidal skvidal at phy.duke.edu
Sat Aug 6 06:54:20 UTC 2005


On Fri, 2005-08-05 at 01:44 -0700, Panu Matilainen wrote:
> On Fri, 5 Aug 2005, seth vidal wrote:
> > On Fri, 2005-08-05 at 01:28 -0700, Panu Matilainen wrote:
> >> Mm, yum.doPackageLists() is just fine, but if it returned a dict instead
> >> of misc.GenericHolder() or the holder behaved like a dict it'd be nicer to
> >> use for certain things, eg:
> >>
> >> ypl = doPackageLists(pkgnarrow=opts.pkgnarrow)
> >> for pkg in ypl[opts.pkgnarrow]:
> >>      ... do stuff ...
> >>
> >> instead of the current situation where you'll need to either have lots of
> >> if's or do something like
> >>
> >> ypl = doPackageLists(pkgnarrow=opts.pkgnarrow)
> >> for pkg in getattr(ypl, opts.pkgnarrow):
> >>      ... do stuff ...
> >>
> >> Any objections to such a change?
> >
> > but I kinda like how pretty
> > ygh.updates  looks, though :)
> >
> > how about just plugging a dict onto the ygh that returns those items
> >
> > ygh.dict['updates'] = ygh.updates
> >
> > hmm
> >
> > I'm not really sure which is hackier, here. :)
> 
> Well, we could just add
> 
> def __getitem__(self, item):
>      if hasattr(self, item):
>          return getattr(self, item)
>      else:
>          raise KeyError, item
> 
> to misc.GenericHolder and have both :)
> 

heh.

whichever floats your boat.
-sv





More information about the Yum-devel mailing list