Added CurveEngine.run_command and reorganized CommandStack._execute
[hooke.git] / hooke / curve.py
index 552eda6abe5582c2bf3b47f1926a8899f3829e77..34fb34e0135c53f58704fa04f4f889c4c833ae22 100644 (file)
@@ -170,6 +170,11 @@ class Curve (object):
         self.info = info
         self.name = os.path.basename(path)
         self.command_stack = CommandStack()
+        self._hooke = None  # Hooke instance for Curve.load()
+
+    def set_hooke(self, hooke=None):
+        if hooke != None:
+            self._hooke = hooke
 
     def identify(self, drivers):
         """Identify the appropriate :class:`hooke.driver.Driver` for
@@ -188,18 +193,21 @@ class Curve (object):
                 return
         raise NotRecognized(self)
 
-    def load(self, *args, **kwargs):
+    def load(self, hooke=None):
         """Use the driver to read the curve into memory.
 
         Also runs any commands in :attr:`command_stack`.  All
         arguments are passed through to
         :meth:`hooke.command_stack.CommandStack.execute`.
         """
+        self.set_hooke(hooke)
         data,info = self.driver.read(self.path, self.info)
         self.data = data
         for key,value in info.items():
             self.info[key] = value
-        self.command_stack.execute(*args, **kwargs)
+        if self.hooke != None:
+            # TODO: set 'curve' argument explicitly for CurveCommands
+            self.command_stack.execute(self.hooke)
 
     def unload(self):
         """Release memory intensive :attr:`.data`.