Add a `Delete` button to the GUI NavBar, and cleanup deletion callbacks.
[hooke.git] / hooke / command_stack.py
index 319d354fe6dc103dfa323a866e9acda50c9e2585..d4e8b026e04acd95babe391cce869a1f99203938 100644 (file)
@@ -1,23 +1,32 @@
-# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
 #
 # This file is part of Hooke.
 #
-# Hooke is free software: you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
+# Hooke is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
 #
-# Hooke is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
-# Public License for more details.
+# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
 #
-# You should have received a copy of the GNU Lesser General Public
-# License along with Hooke.  If not, see
-# <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
 
 """The ``command_stack`` module provides tools for managing and
 executing stacks of :class:`~hooke.engine.CommandMessage`\s.
+
+In experiment analysis, the goal is to construct a
+:class:`~hooke.command_stack.CommandStack` that starts with your raw
+experiment data and ends with your analyzed results.  These
+:class:`~hooke.command_stack.CommandStack`\s are stored in your
+:class:`~hooke.playlist.FilePlaylist`, so they are saved to disk with
+the analysis results.  This means you will always have a record of
+exactly how you processed the raw data to produce your analysis
+results, which makes it easy to audit your approach or go back and
+reanalyze older data.
 """
 
 import os
@@ -118,24 +127,29 @@ class CommandStack (list):
        <CommandMessage CommandB {param: D}>,
        <CommandMessage CommandC {param: E}>]}>
     >>> import yaml
-    >>> print yaml.dump(c)
+    >>> print yaml.dump(c)  # doctest: +REPORT_UDIFF
     !!python/object/new:hooke.command_stack.CommandStack
     listitems:
     - !!python/object:hooke.engine.CommandMessage
       arguments: {param: A}
       command: CommandA
+      explicit_user_call: true
     - !!python/object:hooke.engine.CommandMessage
       arguments: {param: B}
       command: CommandB
+      explicit_user_call: true
     - !!python/object:hooke.engine.CommandMessage
       arguments: {param: C}
       command: CommandA
+      explicit_user_call: true
     - !!python/object:hooke.engine.CommandMessage
       arguments: {param: D}
       command: CommandB
+      explicit_user_call: true
     - !!python/object:hooke.engine.CommandMessage
       arguments: {param: E}
       command: CommandC
+      explicit_user_call: true
     - !!python/object:hooke.engine.CommandMessage
       arguments:
         param: !!python/object/new:hooke.command_stack.CommandStack
@@ -143,19 +157,25 @@ class CommandStack (list):
           - !!python/object:hooke.engine.CommandMessage
             arguments: {param: A}
             command: CommandA
+            explicit_user_call: true
           - !!python/object:hooke.engine.CommandMessage
             arguments: {param: B}
             command: CommandB
+            explicit_user_call: true
           - !!python/object:hooke.engine.CommandMessage
             arguments: {param: C}
             command: CommandA
+            explicit_user_call: true
           - !!python/object:hooke.engine.CommandMessage
             arguments: {param: D}
             command: CommandB
+            explicit_user_call: true
           - !!python/object:hooke.engine.CommandMessage
             arguments: {param: E}
             command: CommandC
+            explicit_user_call: true
       command: CommandD
+      explicit_user_call: true
     <BLANKLINE>
 
     There is also a convenience function for clearing the stack.
@@ -168,19 +188,14 @@ class CommandStack (list):
 
     >>> from .curve import Curve
     >>> c.append(CommandMessage('curve info', {'curve': Curve(path=None)}))
-    >>> print yaml.dump(c)
+    >>> print yaml.dump(c)  # doctest: +REPORT_UDIFF
     !!python/object/new:hooke.command_stack.CommandStack
     listitems:
     - !!python/object:hooke.engine.CommandMessage
       arguments:
-        curve: !!python/object:hooke.curve.Curve
-          command_stack: !!python/object:hooke.command_stack.CommandStack {}
-          data: null
-          driver: null
-          info: {}
-          name: null
-          path: null
+        curve: !!python/object:hooke.curve.Curve {}
       command: curve info
+      explicit_user_call: true
     <BLANKLINE>
     """
     def execute(self, hooke, filter=None, stack=False):