gyang_curve.py: Allow auxiliary files in the curve directory
authorW. Trevor King <wking@tremily.us>
Fri, 19 Apr 2013 15:07:51 +0000 (11:07 -0400)
committerW. Trevor King <wking@tremily.us>
Fri, 19 Apr 2013 15:07:51 +0000 (11:07 -0400)
I haven't bothered to trace this down to a particular version of the
LabVIEW VIs, but some of my archived experiments have the auxiliary
files in a 'params' subdirectory and some do not.  With this patch,
gyang_curve can successfully read both layouts.

posts/Comparing_velocity_clamp_experiments/gyang_curve.py

index 310e5149be94426b00b6f07b08b551c1cd349fe4..7dd9b6dac95ac57611ea7cff7c6abc69177820c3 100755 (executable)
@@ -83,12 +83,13 @@ class Curve (object):
         self.month = time.tm_mon
         self.day = time.tm_mday
         self.series = int(series)
-        self._auxiliary_paths = dict(
-            (aux,
-             _os.path.join(
-                    dirname, 'params', '{}{}_{}'.format(
-                        month_day, aux, series)))
-            for aux in self._auxiliary_files)
+        self._auxiliary_paths = {}
+        for aux in self._auxiliary_files:
+            filename = '{}{}_{}'.format(month_day, aux, series)
+            aux_path = _os.path.join(dirname, filename)
+            if not _os.path.isfile(aux_path):
+                aux_path = _os.path.join(dirname, 'params', filename)
+            self._auxiliary_paths[aux] = aux_path
 
     def _load(self):
         for aux in self._auxiliary_files: