From: W. Trevor King Date: Thu, 12 Aug 2010 11:16:19 +0000 (-0400) Subject: Moved QueueMessage and subclasses from hooke.ui to the more central hooke.engine. X-Git-Url: http://git.tremily.us/?p=hooke.git;a=commitdiff_plain;h=45c5d07228fbe9cefd209012849faa86dd7a020f Moved QueueMessage and subclasses from hooke.ui to the more central hooke.engine. --- diff --git a/hooke/engine.py b/hooke/engine.py index ca4461d..90c652e 100644 --- a/hooke/engine.py +++ b/hooke/engine.py @@ -22,23 +22,43 @@ 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): - """Get a :class:`hooke.ui.QueueMessage` from the incoming + """Get a :class:`QueueMessage` from the incoming `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 - be ready to receive the next :class:`hooke.ui.QueueMessage`. + be ready to receive the next :class:`QueueMessage`. """ log = logging.getLogger('hooke') while True: diff --git a/hooke/plugin/command_stack.py b/hooke/plugin/command_stack.py index bfc15d5..fc696a7 100644 --- a/hooke/plugin/command_stack.py +++ b/hooke/plugin/command_stack.py @@ -18,7 +18,10 @@ # License along with Hooke. If not, see # . -"""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 diff --git a/hooke/ui/__init__.py b/hooke/ui/__init__.py index 6a76b82..1b93914 100644 --- a/hooke/ui/__init__.py +++ b/hooke/ui/__init__.py @@ -23,6 +23,7 @@ import ConfigParser as configparser from .. import version from ..config import Setting +from ..engine import CloseEngine, CommandMessage 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`. """ diff --git a/hooke/ui/commandline.py b/hooke/ui/commandline.py index 53291a2..4b49143 100644 --- a/hooke/ui/commandline.py +++ b/hooke/ui/commandline.py @@ -32,8 +32,9 @@ except ImportError, e: import shlex from ..command import CommandExit, Exit, Command, Argument, StoreValue +from ..engine import CommandMessage 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 diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index b8a8133..8f1e41b 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -46,8 +46,9 @@ import wx.lib.evtmgr as evtmgr from ...command import CommandExit, Exit, Success, Failure, Command, Argument from ...config import Setting +from ...engine import CommandMessage 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 diff --git a/hooke/ui/gui/panel/commands.py b/hooke/ui/gui/panel/commands.py index 5d27cc0..3eefc07 100644 --- a/hooke/ui/gui/panel/commands.py +++ b/hooke/ui/gui/panel/commands.py @@ -3,9 +3,9 @@ """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.