>>> c.clear()
>>> print [repr(cm) for cm in c]
[]
+
+ YAMLize a curve argument.
+
+ >>> from .curve import Curve
+ >>> c.append(CommandMessage('curve info', {'curve': Curve(path=None)}))
+ >>> print yaml.dump(c)
+ !!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
+ command: curve info
+ <BLANKLINE>
"""
def execute(self, hooke, filter=None, stack=False):
"""Execute a stack of commands.
Another important attribute is :attr:`command_stack`, which holds
a :class:`~hooke.command_stack.CommandStack` listing the commands
that have been applied to the `Curve` since loading.
+
+ The data-type is pickleable, to ensure we can move it between
+ processes with :class:`multiprocessing.Queue`\s.
+
+ >>> import pickle
+ >>> import yaml
+ >>> from .engine import CommandMessage
+ >>> c = Curve(path='some/path')
+
+ We add a recursive reference to `c` as you would get from
+ :meth:`hooke.plugin.curve.CurveCommand._add_to_command_stack`.
+
+ >>> c.command_stack.append(CommandMessage('curve info', {'curve':c}))
+
+ >>> s = pickle.dumps(c)
+ >>> z = pickle.loads(s)
+ >>> z
+ <Curve path>
+ >>> z.command_stack[-1].arguments['curve'] == z
+ True
+ >>> print yaml.dump(c)
+ &id001 !!python/object:hooke.curve.Curve
+ command_stack: !!python/object/new:hooke.command_stack.CommandStack
+ listitems:
+ - !!python/object:hooke.engine.CommandMessage
+ arguments:
+ curve: *id001
+ command: curve info
+ data: null
+ driver: null
+ info: {}
+ name: path
+ path: some/path
+ <BLANKLINE>
"""
def __init__(self, path, info=None):
#the data dictionary contains: {name of data: list of data sets [{[x], [y]}]
def __getstate__(self):
state = dict(self.__dict__) # make a copy of the attribute dict.
- state['info'] = dict(self.info) # make a copy of the info dict too.
del(state['_hooke'])
return state