[PATCH 04/13] Create common abstract classes usable for all types of UI
Chris Lumens
clumens at redhat.com
Thu Aug 9 17:20:56 UTC 2012
> @@ -122,7 +126,7 @@ def collect(module_pattern, path, pred):
> continue
>
> mod_name = module_file[:-3]
> - module = importlib.import_module(module_pattern % mod_name))
> + module = importlib.import_module(module_pattern % mod_name)
>
> p = lambda obj: inspect.isclass(obj) and pred(obj)
>
This chunk really ought to be squashed with whatever patch introduced
this line in the first place.
> +class Spoke(UIObject):
...
> + def initialize(self):
> + UIObject.initialize(self)
You don't really need the pass through here.
> +class StandaloneSpoke(NormalSpoke):
> + """A StandaloneSpoke is a Spoke subclass that is displayed apart from any
> + Hub. It is suitable to be used as a Welcome screen.
> +
> + From a layout perspective, a StandaloneSpoke provides a full screen
> + interface. However, it also provides navigation information at the top
> + and bottom of the screen that makes it look like the StandaloneSpoke
> + fits into some other UI element.
> +
> + Class attributes:
> +
> + preForHub/postForHub -- A reference to a Hub subclass this Spoke is
> + either a pre or post action for. Only one of
> + these may be set at a time. Note that all
> + post actions will be run for one hub before
> + any pre actions for the next.
> + priority -- This value is used to sort pre and post
> + actions. The lower a value, the earlier it
> + will be run. So a value of 0 for a post action
> + ensures it will run immediately after a Hub,
> + while a value of 0 for a pre actions means
> + it will run as the first thing.
> + """
> + preForHub = None
> + postForHub = None
> +
> + priority = 100
> +
> + def __init__(self, data, storage, payload, instclass):
> + """Create a StandaloneSpoke instance."""
> + if self.__class__ is StandaloneSpoke:
> + raise TypeError("StandaloneSpoke is an abstract class")
> +
> + if self.preForHub and self.postForHub:
> + raise AttributeError("StandaloneSpoke instance %s may not have both preForHub and postForHub set" % self)
> +
> + Spoke.__init__(self, data, storage, payload, instclass)
> +
> + """A NormalSpoke is a Spoke subclass that is displayed when the user
> + selects something on a Hub. This is what most Spokes in anaconda will
> + be based on.
> +
> + From a layout perspective, a NormalSpoke takes up the entire screen
> + therefore hiding the Hub and its action area. The NormalSpoke also
> + provides some basic navigation information (where you are, what you're
> + installing, how to get back to the Hub) at the top of the screen.
> + """
> + def __init__(self, data, storage, payload, instclass):
> + """Create a NormalSpoke instance."""
> + if self.__class__ is NormalSpoke:
> + raise TypeError("NormalSpoke is an abstract class")
> +
> + Spoke.__init__(self, data, storage, payload, instclass)
> + self.selector = None
Looks like a potential copy-and-paste error here. You've got two
__init__ methods with two intro comment blocks.
- Chris
More information about the anaconda-patches
mailing list