From: W. Trevor King Date: Wed, 8 Sep 2010 14:58:45 +0000 (-0400) Subject: Break JPK data block name extraction out into ._zip_segment_name(). X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=378f0ba6bb8884c5cc2694ca0dba901cd924055d;p=hooke.git Break JPK data block name extraction out into ._zip_segment_name(). Also removes restrictions on allowed names. --- diff --git a/hooke/driver/jpk.py b/hooke/driver/jpk.py index 24d9777..fec6cf5 100644 --- a/hooke/driver/jpk.py +++ b/hooke/driver/jpk.py @@ -174,19 +174,22 @@ class JPKDriver (Driver): def _zip_translate_segment_params(self, params): info = { - 'raw info':params, - 'columns':list(params['channels']['list']), - 'name':params['force-segment-header']['name']['name'], + 'raw info': params, + 'columns': list(params['channels']['list']), + 'name': self._zip_segment_name(params), } - if info['name'] in ['extend-spm', 'retract-spm', 'pause-at-end-spm']: - info['name'] = info['name'][:-len('-spm')] - if info['name'] == 'extend': - info['name'] = 'approach' - else: - raise NotImplementedError( - 'Unrecognized segment type %s' % info['name']) return info + def _zip_segment_name(self, params): + name = params['force-segment-header']['name']['name'] + if name.endswith('-spm'): + name = name[:-len('-spm')] + if name == 'extend': + name = 'approach' + elif name.startswith('pause-at-'): + name = 'pause' + return name + def _zip_scale_segment(self, segment, path, info): data = curve.Data( shape=segment.shape,