Re: [PATCH 5/6] Move all the important stuff out of the KickstartCommand.parse methods.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > +    def add(self, obj):
> > +        if isinstance(obj, KickstartCommand):
> > +            # Commands can only be run once, and the latest one seen takes
> > +            # precedence over any earlier ones.
> > +            i = 0
> > +            while i < len(self._dataObjs):
> > +                if self._dataObjs[i].__class__ == obj.__class__:
> > +                    break
> > +
> > +                i += 1
> > +
> > +            if i == len(self._dataObjs):
> > +                self._dataObjs.append(obj)
> > +            else:
> > +                self._dataObjs[i] = obj
> 
> Shouldn't this instead remove the now-obsolete earlier command from the
> list and then append the new one to the end of the list? As it stands,
> you're not really preserving the ordering.

Yes, yes it should.  Good catch.  So, add should look more like this:

def add(self, obj):
    if isinstance(obj, KickstartCommand):
        # Commands can only be run once, and the latest one seen takes
        # precedence over any earlier ones.
        i = 0
        while i < len(self._dataObjs):
            if self._dataObjs[i].__class__ == obj.__class__:
                self._dataObjs.pop(i)
                break

            i += 1

        self._dataObjs.append(obj)
    ...


- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux