[PATCH 3/4] Fix up collectCategoriesAndSpokes function.

Vratislav Podzimek vpodzime at redhat.com
Wed Jun 4 12:12:18 UTC 2014


On Wed, 2014-06-04 at 08:10 -0400, Samantha N. Bueno wrote:
> On Wed, Jun 04, 2014 at 01:14:58PM +0200, Vratislav Podzimek wrote:
> > On Tue, 2014-06-03 at 11:01 -0400, Samantha N. Bueno wrote:
> > > Text mode displays everything on the summary hub, whereas some spokes
> > > are displayed on the progress hub as well in graphical. Default values
> > > in the spoke category files are for the GUI, so this just tweaks the
> > > collectCategoriesAndSpokes function a little to make text mode ignore
> > > which hub spokes should be shown on.
> > > ---
> > >  pyanaconda/ui/common.py | 17 ++++++++++++-----
> > >  1 file changed, 12 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
> > > index fcbcdb6..08409ff 100644
> > > --- a/pyanaconda/ui/common.py
> > > +++ b/pyanaconda/ui/common.py
> > > @@ -28,7 +28,7 @@ import types
> > >  
> > >  from pyanaconda.constants import ANACONDA_ENVIRON, FIRSTBOOT_ENVIRON
> > >  from pyanaconda.errors import RemovedModuleError
> > > -from pykickstart.constants import FIRSTBOOT_RECONFIG
> > > +from pykickstart.constants import FIRSTBOOT_RECONFIG, DISPLAY_MODE_TEXT
> > >  
> > >  import logging
> > >  log = logging.getLogger("anaconda")
> > > @@ -529,7 +529,7 @@ class Hub(UIObject):
> > >             by a custom collect method.
> > >             One example of such usage is the Initial Setup application.
> > >          """
> > > -        return collectCategoriesAndSpokes(self.paths, self.__class__)
> > > +        return collectCategoriesAndSpokes(self.paths, self.__class__, self.data.displaymode.displayMode)
> > >  
> > >      def exit_logger(self):
> > >          """Log when a user leaves the hub.  Subclasses may override this
> > > @@ -708,7 +708,7 @@ def collect_categories(mask_paths):
> > >  
> > >      return categories
> > >  
> > > -def collectCategoriesAndSpokes(paths, klass):
> > > +def collectCategoriesAndSpokes(paths, klass, displaymode):
> > >      """collects categories and spokes to be displayed on this Hub
> > >  
> > >         :param paths: dictionary mapping categories, spokes, and hubs to their
> > > @@ -719,8 +719,15 @@ def collectCategoriesAndSpokes(paths, klass):
> > >      ret = {}
> > >      # Collect all the categories this hub displays, then collect all the
> > >      # spokes belonging to all those categories.
> > > -    categories = sorted(filter(lambda c: c.displayOnHub == klass, collect_categories(paths["categories"])),
> > > -                        key=lambda c: c.sortOrder)
> > > +    if displaymode == DISPLAY_MODE_TEXT:
> > > +        # bit of a hack, but the category displayOnHub defaults to GUI values,
> > > +        # so just ignore displayOnHub if we're doing a text install since
> > > +        # everything goes on the summary hub anyway
> > > +        categories = sorted(collect_categories(paths["categories"]),
> > > +                            key=lambda c: c.sortOrder)
> > > +    else:
> > > +        categories = sorted(filter(lambda c: c.displayOnHub == klass.__name__, collect_categories(paths["categories"])),
> > > +                            key=lambda c: c.sortOrder)
> > >      for c in categories:
> > >          ret[c] = collect_spokes(paths["spokes"], c.__name__)
> > This effectively means there will never be more hubs in the text mode
> > which I'm not sure is what we really want. Couldn't we have two
> > displayOnHub attributes (GUI and TUI) instead?
> 
> Yeah, actually. I'm thinking set displayOnHubTUI and displayOnHubGUI in
> each category, and then collectCategoriesAndSpokes would have its check
> like this:
> 
>     if displaymode = DISPLAY_MODE_TEXT:
>         categories = sorted(filter(lambda c: c.displayOnHubTUI = klass.__name__, collect_categories(paths["categories"])),
>                             key=lambda c: c.sortOrder)
>     else:
>         categories = sorted(filter(lambda c: c.displayOnHubGUI = klass.__name__, collect_categories(paths["categories"])),
>                             key=lambda c: c.sortOrder)
>         
> That should take care of it.
This looks good to me. Thanks!

-- 
Vratislav Podzimek

Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic




More information about the anaconda-patches mailing list