Add os.path.expanduser() wrappers to user-supplied paths.
[hooke.git] / hooke / plugin / curve.py
index 92e5bd1bb8a1aeba4b5ca90597c6f685d154fe0d..7f1190042f4898130cc6e0512f311cf27f9c24d3 100644 (file)
@@ -25,6 +25,7 @@ associated :class:`hooke.command.Command`\s for handling
 """
 
 import copy
+import os.path
 import re
 
 import numpy
@@ -292,8 +293,8 @@ class InfoCommand (CurveCommand):
             Argument(name='all', type='bool', default=False, count=1,
                      help='Get all curve information.'),
             ]
-        self.fields = ['name', 'path', 'experiment', 'driver', 'filetype',
-                       'note', 'command stack', 'blocks', 'block sizes']
+        self.fields = ['name', 'path', 'driver', 'note', 'command stack',
+                       'blocks', 'block names', 'block sizes']
         for field in self.fields:
             args.append(Argument(
                     name=field, type='bool', default=False, count=1,
@@ -325,15 +326,9 @@ class InfoCommand (CurveCommand):
     def _get_path(self, curve):
         return curve.path
 
-    def _get_experiment(self, curve):
-        return curve.info.get('experiment', None)
-
     def _get_driver(self, curve):
         return curve.driver
 
-    def _get_filetype(self, curve):
-        return curve.info.get('filetype', None)
-
     def _get_note(self, curve):
         return curve.info.get('note', None)
                               
@@ -343,6 +338,9 @@ class InfoCommand (CurveCommand):
     def _get_blocks(self, curve):
         return len(curve.data)
 
+    def _get_block_names(self, curve):
+        return [block.info['name'] for block in curve.data]
+
     def _get_block_sizes(self, curve):
         return [block.shape for block in curve.data]
 
@@ -388,8 +386,9 @@ File name for the output (appended).
                         else:
                             keys.append((index+1, new_stack, v))
                 if matched == False:
-                    raise ValueError('no match found for %s in %s'
-                                     % (key_stack[index], key))
+                    raise ValueError(
+                        'no match found for %s (%s) in %s'
+                        % (key_stack[index], key, sorted(info.keys())))
         if params['output'] != None:
             curve = self._curve(hooke, params)
             with open(params['output'], 'a') as f:
@@ -461,7 +460,7 @@ True if you want the column-naming header line.
     def _run(self, hooke, inqueue, outqueue, params):
         data = self._block(hooke, params)
 
-        with open(params['output'], 'w') as f:
+        with open(os.path.expanduser(params['output']), 'w') as f:
             if params['header'] == True:
                 f.write('# %s \n' % ('\t'.join(data.info['columns'])))
             numpy.savetxt(f, data, delimiter='\t')