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

[PATCH 1/2] Return the KickstartCommand/KickstartData object from dispatcher.



When the dispatcher calls out to a KickstartCommand, it gets a return value
that is either the KickstartCommand populated with data, or a KickstartData
also populated with data.  It'd be nice to make that return value available
in handleCommand, and then again in whatever calls handleCommand.
---
 pykickstart/base.py   |    5 ++++-
 pykickstart/parser.py |    7 +++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/pykickstart/base.py b/pykickstart/base.py
index 07a68b9..b522878 100644
--- a/pykickstart/base.py
+++ b/pykickstart/base.py
@@ -352,7 +352,8 @@ class BaseHandler(KickstartObject):
     def dispatcher(self, args, lineno, include=None):
         """Call the appropriate KickstartCommand handler for the current line
            in the kickstart file.  A handler for the current command should
-           be registered, though a handler of None is not an error.
+           be registered, though a handler of None is not an error.  Returns
+           the data object returned by KickstartCommand.parse.
 
            args    -- A list of arguments to the current command
            lineno  -- The line number in the file, for error reporting
@@ -381,6 +382,8 @@ class BaseHandler(KickstartObject):
             if include is not None:
                 obj.preceededInclude = include
 
+            return obj
+
     def maskAllExcept(self, lst):
         """Set all entries in the commands dict to None, except the ones in
            the lst.  All other commands will not be processed.
diff --git a/pykickstart/parser.py b/pykickstart/parser.py
index 865514a..160874c 100644
--- a/pykickstart/parser.py
+++ b/pykickstart/parser.py
@@ -462,15 +462,18 @@ class KickstartParser:
 
     def handleCommand (self, lineno, args):
         """Given the list of command and arguments, call the Version's
-           dispatcher method to handle the command.  This method may be
+           dispatcher method to handle the command.  Returns the command or
+           data object returned by the dispatcher.  This method may be
            overridden in a subclass if necessary.
         """
         if self.handler:
             self.handler.currentCmd = args[0]
             self.handler.currentLine = self._line
-            self.handler.dispatcher(args, lineno, self._preceededInclude)
+            retval = self.handler.dispatcher(args, lineno, self._preceededInclude)
             self._preceededInclude = None
 
+            return retval
+
     def handlePackageHdr (self, lineno, args):
         """Process the arguments to the %packages header and set attributes
            on the Version's Packages instance appropriate.  This method may be
-- 
1.6.5.1


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