[PATCH] Fix the way categories are handled in text mode.

Martin Kolman mkolman at redhat.com
Mon May 5 11:47:45 UTC 2014


On Mon, 2014-05-05 at 13:26 +0200, Martin Kolman wrote:
> On Mon, 2014-05-05 at 13:17 +0200, Vratislav Podzimek wrote:
> > On Fri, 2014-05-02 at 16:56 +0200, Martin Kolman wrote:
> > > From: "Samantha N. Bueno" <sbueno+anaconda at redhat.com>
> > > 
> > > This statically maintained list of spoke categories for text mode has
> > > been bothering me for almost a year, so it's time to get rid of it.
> > > 
> > > This now more or less mirrors the GUI logic we have for handling spoke
> > > categories. I wanted to originally make the category classes something
> > > that could be used by both GUI and TUI to reduce duplication, but it is
> > > not meant to be.
> > > 
> > > This also moves the collectCategoriesAndSpokes, collect_categories, and
> > > collect_spokes functions into pyanaconda.ui.common since I could at
> > > least consolidate that.
> > > 
> > > Signed-off-by: Martin Kolman <mkolman at redhat.com>
> > > ---
> > >  po/POTFILES.in                                |  6 ++++
> > >  pyanaconda/ui/common.py                       | 51 +++++++++++++++++++++++++++
> > >  pyanaconda/ui/gui/categories/__init__.py      | 13 +------
> > >  pyanaconda/ui/gui/hubs/__init__.py            | 21 +----------
> > >  pyanaconda/ui/gui/spokes/__init__.py          | 20 +----------
> > >  pyanaconda/ui/tui/__init__.py                 |  4 +++
> > >  pyanaconda/ui/tui/categories/Makefile.am      | 22 ++++++++++++
> > >  pyanaconda/ui/tui/categories/__init__.py      | 46 ++++++++++++++++++++++++
> > >  pyanaconda/ui/tui/categories/customization.py | 32 +++++++++++++++++
> > >  pyanaconda/ui/tui/categories/localization.py  | 31 ++++++++++++++++
> > >  pyanaconda/ui/tui/categories/software.py      | 31 ++++++++++++++++
> > >  pyanaconda/ui/tui/categories/system.py        | 32 +++++++++++++++++
> > >  pyanaconda/ui/tui/categories/user_settings.py | 32 +++++++++++++++++
> > >  pyanaconda/ui/tui/hubs/__init__.py            | 22 ++++++------
> > >  pyanaconda/ui/tui/hubs/summary.py             |  2 --
> > >  pyanaconda/ui/tui/spokes/__init__.py          | 24 ++-----------
> > >  pyanaconda/ui/tui/spokes/askvnc.py            |  2 --
> > >  pyanaconda/ui/tui/spokes/network.py           |  3 +-
> > >  pyanaconda/ui/tui/spokes/password.py          |  3 +-
> > >  pyanaconda/ui/tui/spokes/shell_spoke.py       |  3 +-
> > >  pyanaconda/ui/tui/spokes/software.py          |  3 +-
> > >  pyanaconda/ui/tui/spokes/source.py            | 11 +++---
> > >  pyanaconda/ui/tui/spokes/storage.py           |  7 ++--
> > >  pyanaconda/ui/tui/spokes/time_spoke.py        |  3 +-
> > >  pyanaconda/ui/tui/spokes/user.py              |  3 +-
> > >  25 files changed, 325 insertions(+), 102 deletions(-)
> > >  create mode 100644 pyanaconda/ui/tui/categories/Makefile.am
> > >  create mode 100644 pyanaconda/ui/tui/categories/__init__.py
> > >  create mode 100644 pyanaconda/ui/tui/categories/customization.py
> > >  create mode 100644 pyanaconda/ui/tui/categories/localization.py
> > >  create mode 100644 pyanaconda/ui/tui/categories/software.py
> > >  create mode 100644 pyanaconda/ui/tui/categories/system.py
> > >  create mode 100644 pyanaconda/ui/tui/categories/user_settings.py
> > > 
> > > diff --git a/po/POTFILES.in b/po/POTFILES.in
> > > index 358534c..e48469e 100644
> > > --- a/po/POTFILES.in
> > > +++ b/po/POTFILES.in
> > > @@ -62,6 +62,12 @@ pyanaconda/ui/tui/spokes/warnings.py
> > >  pyanaconda/ui/tui/spokes/progress.py
> > >  pyanaconda/ui/tui/spokes/__init__.py
> > >  pyanaconda/ui/tui/__init__.py
> > > +pyanaconda/ui/tui/categories/__init__.py
> > > +pyanaconda/ui/tui/categories/customization.py
> > > +pyanaconda/ui/tui/categories/localization.py
> > > +pyanaconda/ui/tui/categories/software.py
> > > +pyanaconda/ui/tui/categories/system.py
> > > +pyanaconda/ui/tui/categories/user_settings.py
> > >  
> > >  # Graphical interface
> > >  pyanaconda/ui/gui/__init__.py
> > > diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
> > > index 9e2782d..470d4c0 100644
> > > --- a/pyanaconda/ui/common.py
> > > +++ b/pyanaconda/ui/common.py
> > > @@ -524,6 +524,13 @@ class Hub(UIObject):
> > >          """
> > >          log.debug("Entered hub: %s", self.__class__.__name__)
> > >  
> > > +    def _collectCategoriesAndSpokes(self):
> > > +        """This method is provided so that is can be overridden in a subclass
> > > +           by a custom collect method.
> > > +           One example of such usage is the Initial Setup application.
> > > +        """
> > > +        return collectCategoriesAndSpokes(self.paths, self.__class__)
> > > +
> > >      def exit_logger(self):
> > >          """Log when a user leaves the hub.  Subclasses may override this
> > >             method if they want to log more specific information, but an
> > > @@ -673,3 +680,47 @@ def collect(module_pattern, path, pred):
> > >  
> > >      return retval
> > >  
> > > +def collect_spokes(mask_paths, category):
> > > +    """Return a list of all spoke subclasses that should appear for a given
> > > +       category. Look for them in files imported as module_path % basename(f)
> > > +
> > > +       :param mask_paths: list of mask, path tuples to search for classes
> > > +       :type mask_paths: list of (mask, path)
> > > +
> > > +       :return: list of Spoke classes belonging to category
> > > +       :rtype: list of Spoke classes
> > > +
> > > +    """
> > > +    spokes = []
> > > +    for mask, path in mask_paths:
> > > +        spokes.extend(collect(mask, path, lambda obj: hasattr(obj, "category") and obj.category != None and obj.category.__name__ == category))
> > While moving this code, please split this line into (at least) two.
> > 
> Sure, will do that.
And when I'm at it I'll also replace the "!= None" comparisons by "is
not None".
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches




More information about the anaconda-patches mailing list