self.aliases = aliases
self.arguments = [
Argument(name='help', type='bool', default=False, count=1,
- callback=StoreValue(True), help='Print a help message.'),
+ help='Print a help message.'),
] + arguments
self._help = help
if name != argument.name:
params.remove(name)
params[argument.name] = value
- if argument.callback != None:
- value = argument.callback(hooke, self, argument, value)
- params[argument.name] = value
+ if argument.callback != None:
+ value = argument.callback(hooke, self, argument, value)
+ params[argument.name] = value
argument.validate(value)
return params
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-'''
-hooke_cli.py
-
-Command line module of Hooke.
-
-Copyright (C) 2006 Massimo Sandal (University of Bologna, Italy).
-
-This program is released under the GNU General Public License version 2.
-'''
-
-from .libhooke import HOOKE_VERSION, WX_GOOD
-
-import wxversion
-wxversion.select(WX_GOOD)
-import wx
-
-from wx.lib.newevent import NewEvent
-from matplotlib.numerix import * #FIXME
-
-import xml.dom.minidom
-import sys, os, os.path, glob, shutil
-import Queue
-import cmd
-import time
-
-global __version__
-global __codename__
-global __releasedate__
-__version__ = HOOKE_VERSION[0]
-__codename__ = HOOKE_VERSION[1]
-__releasedate__ = HOOKE_VERSION[2]
-
-from matplotlib import __version__ as mpl_version
-from wx import __version__ as wx_version
-from wxmpl import __version__ as wxmpl_version
-from scipy import __version__ as scipy_version
-from numpy import __version__ as numpy_version
-from sys import version as python_version
-import platform
-
-from .libhooke import PlaylistXML
-from . import curve as lhc
-from . import libinput as linp
-from . import liboutlet as lout
-
-
class HookeCli(cmd.Cmd, object):
def __init__(self,frame,list_of_events,events_from_gui,config,drivers):
shutil.copy(item.path, mydir)
except (OSError, IOError):
print 'Cannot copy file. '+item.path+' Perhaps you gave me a wrong directory?'
-
-#OUTLET management
-#-----------------
- def do_outlet_show(self,args):
- '''OUTLET_SHOW
- ---------
- Shows current content of outlet with index for reference
- '''
- self.outlet.printbuf()
-
- def do_outlet_undo(self, args):
- '''OUTLET_UNDO
- ---------
- Eliminates last entry in outlet
- '''
- print 'Erasing last entry'
- self.outlet.pop()
-
- def do_outlet_delete(self, args):
- '''OUTLET_DELETE
- Eliminates a particular entry from outlet
- Syntax: outlet_delete n
- '''
- if len(args)==0:
- print 'Index needed!, use outlet_show to know it'
- else:
- self.outlet.delete(args)
-
-if __name__ == '__main__':
- mycli=HookeCli(0)
- mycli.cmdloop()
return [NextCommand(), PreviousCommand(), JumpCommand(),
SaveCommand(), LoadCommand(),
AddCommand(), AddGlobCommand(),
- RemoveCommand(), FilterCommand()]
+ RemoveCommand(), FilterCommand(), NoteFilterCommand()]
# Define common or complicated arguments
p = params['playlist'].filter(params['filter'])
hooke.playlists.add(p)
outqueue.put(p)
+
+class NoteFilterCommand (FilterCommand):
+ """Create a subset playlist of curves with `.info['note'] != None`.
+ """
+ def __init__(self):
+ super(NoteFilterCommand, self).__init__()
+ self.name = 'note filter playlist'
+ self.arguments = [a for a in self.arguments if a.name != 'filter']
+
+ def _run(self, hooke, inqueue, outqueue, params):
+ params['filter'] = lambda curve : \
+ 'note' in curve.info and curve.info['note'] != None
+ return super(NoteFilterCommand, self)._run(
+ hooke, inqueue, outqueue, params)
name='exit', aliases=['quit', 'EOF'], help=self.__doc__,
arguments = [
Argument(name='force', type='bool', default=False,
- callback=StoreValue(True), help="""
+ help="""
Exit without prompting the user. Use if you save often or don't make
typing mistakes ;).
""".strip()),