Moved QueueMessage and subclasses from hooke.ui to the more central hooke.engine.
authorW. Trevor King <wking@drexel.edu>
Thu, 12 Aug 2010 11:16:19 +0000 (07:16 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 12 Aug 2010 11:16:19 +0000 (07:16 -0400)
hooke/engine.py
hooke/plugin/command_stack.py
hooke/ui/__init__.py
hooke/ui/commandline.py
hooke/ui/gui/__init__.py
hooke/ui/gui/panel/commands.py

index ca4461d9bc6800de936b6f740d667ca02c7c969a..90c652ed47f40bbee51ceb3f53dd93257a6235f1 100644 (file)
 
 import logging
 
 
 import logging
 
-from .ui import CloseEngine, CommandMessage
+
+class QueueMessage (object):
+    def __str__(self):
+        return self.__class__.__name__
+
+
+class CloseEngine (QueueMessage):
+    pass
+
+
+class CommandMessage (QueueMessage):
+    """A message storing a command to run, `command` should be a
+    :class:`hooke.command.Command` instance, and `arguments` should be
+    a :class:`dict` with `argname` keys and `value` values to be
+    passed to the command.
+    """
+    def __init__(self, command, arguments=None):
+        self.command = command
+        if arguments == None:
+            arguments = {}
+        self.arguments = arguments
 
 
 class CommandEngine (object):
     def run(self, hooke, ui_to_command_queue, command_to_ui_queue):
 
 
 class CommandEngine (object):
     def run(self, hooke, ui_to_command_queue, command_to_ui_queue):
-        """Get a :class:`hooke.ui.QueueMessage` from the incoming
+        """Get a :class:`QueueMessage` from the incoming
         `ui_to_command_queue` and act accordingly.
 
         `ui_to_command_queue` and act accordingly.
 
-        If the message is a :class:`hooke.ui.CommandMessage` instance,
-        the command run may read subsequent input from
+        If the message is a :class:`CommandMessage` instance, the
+        command run may read subsequent input from
         `ui_to_command_queue` (if it is an interactive command).  The
         command may also put assorted data into `command_to_ui_queue`.
 
         When the command completes, it will put a
         :class:`hooke.command.CommandExit` instance into
         `command_to_ui_queue`, at which point the `CommandEngine` will
         `ui_to_command_queue` (if it is an interactive command).  The
         command may also put assorted data into `command_to_ui_queue`.
 
         When the command completes, it will put a
         :class:`hooke.command.CommandExit` instance into
         `command_to_ui_queue`, at which point the `CommandEngine` will
-        be ready to receive the next :class:`hooke.ui.QueueMessage`.
+        be ready to receive the next :class:`QueueMessage`.
         """
         log = logging.getLogger('hooke')
         while True:
         """
         log = logging.getLogger('hooke')
         while True:
index bfc15d5578296537461f3e41b543a2a10a462a5c..fc696a76a003742031e67187a73c02b6711e9de3 100644 (file)
 # License along with Hooke.  If not, see
 # <http://www.gnu.org/licenses/>.
 
 # License along with Hooke.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-"""Records, saves and executes batches of commands
+"""The ``command_stack`` module provides :class:`CommandStackPlugin`
+and several associated :class:`~hooke.command.Command`\s for managing
+stacks of :class:`~hooke.engine.CommandMessage`\s and applying those
+stacks to :class:`~hooke.curve.Curve`\s.
 """
 
 import os.path
 """
 
 import os.path
index 6a76b82e5356c8b3a764b8d4542d1833766f4d27..1b939144b6f2c1c1f693bca8088891507661e982 100644 (file)
@@ -23,6 +23,7 @@ import ConfigParser as configparser
 
 from .. import version
 from ..config import Setting
 
 from .. import version
 from ..config import Setting
+from ..engine import CloseEngine, CommandMessage
 from ..util.pluggable import IsSubclass, construct_odict
 
 try:
 from ..util.pluggable import IsSubclass, construct_odict
 
 try:
@@ -47,25 +48,6 @@ USER_INTERFACE_SETTING_SECTION = 'user interfaces'
 """
 
 
 """
 
 
-class QueueMessage (object):
-    def __str__(self):
-        return self.__class__.__name__
-
-class CloseEngine (QueueMessage):
-    pass
-
-class CommandMessage (QueueMessage):
-    """A message storing a command to run, `command` should be a
-    :class:`hooke.command.Command` instance, and `arguments` should be
-    a :class:`dict` with `argname` keys and `value` values to be
-    passed to the command.
-    """
-    def __init__(self, command, arguments=None):
-        self.command = command
-        if arguments == None:
-            arguments = {}
-        self.arguments = arguments
-
 class UserInterface (object):
     """A user interface to drive the :class:`hooke.engine.CommandEngine`.
     """
 class UserInterface (object):
     """A user interface to drive the :class:`hooke.engine.CommandEngine`.
     """
index 53291a25e1a4df2420fb0f43dcfbf1e1302d8b61..4b4914398b896682b0b6edee0e30ec3432e6a407 100644 (file)
@@ -32,8 +32,9 @@ except ImportError, e:
 import shlex
 
 from ..command import CommandExit, Exit, Command, Argument, StoreValue
 import shlex
 
 from ..command import CommandExit, Exit, Command, Argument, StoreValue
+from ..engine import CommandMessage
 from ..interaction import Request, BooleanRequest, ReloadUserInterfaceConfig
 from ..interaction import Request, BooleanRequest, ReloadUserInterfaceConfig
-from ..ui import UserInterface, CommandMessage
+from ..ui import UserInterface
 from ..util.convert import from_string
 from ..util.encoding import get_input_encoding, get_output_encoding
 
 from ..util.convert import from_string
 from ..util.encoding import get_input_encoding, get_output_encoding
 
index b8a81336d39e4e2863d07b20760802719aeef5a4..8f1e41bfcf81635bf999539bc221d359dfcbae27 100644 (file)
@@ -46,8 +46,9 @@ import wx.lib.evtmgr as evtmgr
 
 from ...command import CommandExit, Exit, Success, Failure, Command, Argument
 from ...config import Setting
 
 from ...command import CommandExit, Exit, Success, Failure, Command, Argument
 from ...config import Setting
+from ...engine import CommandMessage
 from ...interaction import Request, BooleanRequest, ReloadUserInterfaceConfig
 from ...interaction import Request, BooleanRequest, ReloadUserInterfaceConfig
-from ...ui import UserInterface, CommandMessage
+from ...ui import UserInterface
 from .dialog.selection import Selection as SelectionDialog
 from .dialog.save_file import select_save_file
 from . import menu as menu
 from .dialog.selection import Selection as SelectionDialog
 from .dialog.save_file import select_save_file
 from . import menu as menu
index 5d27cc0e4bdaeede7ccc743ef937c42c1a3755da..3eefc0759f91cbc04397a25a34d9697185ffe44c 100644 (file)
@@ -3,9 +3,9 @@
 """Commands and settings panel for Hooke.
 
 This panel handles command generation of
 """Commands and settings panel for Hooke.
 
 This panel handles command generation of
-:class:`hooke.ui.CommandMessage`\s for all of the commands that don't
-have panels of their own.  Actually it can generate
-:class:`hooke.ui.CommandMessage`\s for those as well, but the
+:class:`hooke.engine.CommandMessage`\s for all of the commands that
+don't have panels of their own.  Actually it can generate
+:class:`hooke.engine.CommandMessage`\s for those as well, but the
 command-specific panel will probably have a nicer interface.
 
 # TODO: command arguments.
 command-specific panel will probably have a nicer interface.
 
 # TODO: command arguments.