[PATCH 12/16] Change how we specify the paths
Martin Sivak
msivak at redhat.com
Thu Dec 6 15:46:35 UTC 2012
---
pyanaconda/ui/__init__.py | 29 ++++++-----------------------
pyanaconda/ui/common.py | 7 ++++++-
pyanaconda/ui/gui/__init__.py | 22 ++++++++++------------
pyanaconda/ui/gui/spokes/password.py | 4 ++++
pyanaconda/ui/tui/__init__.py | 11 ++++++++---
5 files changed, 34 insertions(+), 39 deletions(-)
diff --git a/pyanaconda/ui/__init__.py b/pyanaconda/ui/__init__.py
index 26e540a..3f39a7a 100644
--- a/pyanaconda/ui/__init__.py
+++ b/pyanaconda/ui/__init__.py
@@ -22,8 +22,7 @@
__all__ = ["UserInterface"]
import os
-import inspect
-from common import collect
+from .common import collect, PathDict
class UserInterface(object):
"""This is the base class for all kinds of install UIs. It primarily
@@ -60,27 +59,11 @@ class UserInterface(object):
from pyanaconda.errors import errorHandler
errorHandler.ui = self
- @property
- def basepath(self):
- """returns the directory name for UI subtree"""
- return os.path.dirname(inspect.getfile(self.__class__))
-
- @property
- def basemask(self):
- """returns the python module name for basepath directory"""
- return "pyanaconda.ui"
-
- @property
- def paths(self):
- """return dictionary mapping plugin elements (spokes, hubs, categories)
- to a list of tuples (module mask, search path)"""
- return {
- "spokes": [(self.basemask + ".spokes.%s",
- os.path.join(self.basepath, "spokes"))],
- "hubs": [(self.basemask + ".hubs.%s",
- os.path.join(self.basepath, "hubs"))]
- }
-
+
+ basepath = os.path.dirname(__file__)
+ basemask = "pyanaconda.ui"
+ paths = PathDict({})
+
def setup(self, data):
"""Construct all the objects required to implement this interface.
This method must be provided by all subclasses.
diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index af1e5f9..b1a8dd3 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -29,7 +29,12 @@ class PathDict(dict):
"""Dictionary class supporting + operator"""
def __add__(self, ext):
new_dict = copy.copy(self)
- new_dict.update(ext)
+ for key, value in ext.iteritems():
+ try:
+ new_dict[key].extend(value)
+ except KeyError:
+ new_dict[key] = value[:]
+
return new_dict
class UIObject(object):
diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index 0af036d..2056307 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -247,9 +247,16 @@ class GraphicalUserInterface(UserInterface):
# requires elementrs with 3rd party libraries
from gi.repository import AnacondaWidgets
- @property
- def basemask(self):
- return "pyanaconda.ui.gui"
+ basemask = "pyanaconda.ui.gui"
+ basepath = os.path.dirname(__file__)
+ paths = UserInterface.paths + {
+ "categories": [(basemask + ".categories.%s",
+ os.path.join(basepath, "categories"))],
+ "spokes": [(basemask + ".spokes.%s",
+ os.path.join(basepath, "spokes"))],
+ "hubs": [(basemask + ".hubs.%s",
+ os.path.join(basepath, "hubs"))]
+ }
def _list_hubs(self):
"""Return a list of Hub classes to be imported to this interface"""
@@ -280,15 +287,6 @@ class GraphicalUserInterface(UserInterface):
# Second, order them according to their relationship
return self._orderActionClasses(standalones, hubs)
- @property
- def paths(self):
- _paths = UserInterface.paths.fget(self)
- _paths.update({"categories": [(self.basemask + ".categories.%s",
- os.path.join(self.basepath, "categories"))]
- })
- return _paths
-
-
def _instantiateAction(self, actionClass):
from spokes import StandaloneSpoke
diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py
index c273846..1bd424c 100644
--- a/pyanaconda/ui/gui/spokes/password.py
+++ b/pyanaconda/ui/gui/spokes/password.py
@@ -47,6 +47,10 @@ class PasswordSpoke(NormalSpoke):
icon = "dialog-password-symbolic"
title = N_("ROOT PASSWORD")
+ @classmethod
+ def firstboot(cls):
+ return True
+
def __init__(self, *args):
NormalSpoke.__init__(self, *args)
self._password = None
diff --git a/pyanaconda/ui/tui/__init__.py b/pyanaconda/ui/tui/__init__.py
index cccbf70..b715d0a 100644
--- a/pyanaconda/ui/tui/__init__.py
+++ b/pyanaconda/ui/tui/__init__.py
@@ -129,9 +129,14 @@ class TextUserInterface(ui.UserInterface):
ui.UserInterface.__init__(self, storage, payload, instclass)
self._app = None
- @property
- def basemask(self):
- return "pyanaconda.ui.tui"
+ basemask = "pyanaconda.ui.tui"
+ basepath = os.path.dirname(__file__)
+ paths = ui.UserInterface.paths + {
+ "spokes": [(basemask + ".spokes.%s",
+ os.path.join(basepath, "spokes"))],
+ "hubs": [(basemask + ".hubs.%s",
+ os.path.join(basepath, "hubs"))]
+ }
def _list_hubs(self):
"""returns the list of hubs to use"""
--
1.7.11.7
More information about the anaconda-patches
mailing list