From: W. Trevor King Date: Wed, 11 Aug 2010 23:46:46 +0000 (-0400) Subject: Updated FlatFilterCommand's argument handling. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=caed53651737331ad30de45a9342ca7947e47a3d;p=hooke.git Updated FlatFilterCommand's argument handling. --- diff --git a/hooke/plugin/flatfilt.py b/hooke/plugin/flatfilt.py index 7c0b534..2688bba 100644 --- a/hooke/plugin/flatfilt.py +++ b/hooke/plugin/flatfilt.py @@ -84,7 +84,10 @@ Minimum number of peaks for curve acceptance. self._settings.append(argument_to_setting( self.setting_section, argument)) argument.default = None # if argument isn't given, use the config. - self._commands = [FlatPeaksCommand(self), FlatFilterCommand(self)] + self._commands = [FlatPeaksCommand(self)] + # append FlatFilterCommand so it can steal arguments from + # FlatPeaksCommand. + self._commands.append(FlatFilterCommand(self)) def dependencies(self): return ['vclamp'] @@ -171,7 +174,8 @@ dictionary. raise Failure('%s operates on VelocityClamp experiments, not %s' % (self.name, curve.info['experiment'])) for key,value in params.items(): - if value == None: # Use configured default value. + if value == None and key in self.plugin.config: + # Use configured default value. params[key] = self.plugin.config[key] # TODO: convert 'see double' from nm to points name,def_unit = split_data_label(params['deflection column']) @@ -209,9 +213,15 @@ class FlatFilterCommand (FilterCommand): FlatPeaksCommand : Underlying flat-based peak detection. """ def __init__(self, plugin): + flat_peaks = [c for c in plugin._commands + if c.name == 'flat filter peaks'][0] + flat_peaks_arg_names = [a.name for a in flat_peaks.arguments] + plugin_arguments = [a for a in plugin._arguments + if a.name not in flat_peaks_arg_names] + arguments = flat_peaks.arguments + plugin_arguments super(FlatFilterCommand, self).__init__( plugin, name='flat filter playlist') - self.arguments.extend(plugin._arguments) # TODO: curve & block arguments + self.arguments.extend(arguments) def filter(self, curve, hooke, inqueue, outqueue, params): params['curve'] = curve @@ -226,7 +236,8 @@ class FlatFilterCommand (FilterCommand): return False if not (isinstance(peaks, list) and (len(peaks) == 0 or isinstance(peaks[0], Peak))): - raise Failure('Expected a list of Peaks, not %s' % peaks) + raise Failure('Expected a list of Peaks, not %s: %s' + % (type(peaks), peaks)) ret = outq.get() if not isinstance(ret, Success): raise ret