Fix existing Driver.is_me's crashes if path is a directory.
[hooke.git] / hooke / driver / hemingway.py
index 7fecbb01c9ad7f714592b124db45e421fe63c5c1..5803800191d6e8c942b3b1e78c2a888faed2ea17 100644 (file)
@@ -3,15 +3,15 @@
 #
 # This file is part of Hooke.
 #
-# Hooke is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either
-# version 3 of the License, or (at your option) any later version.
+# Hooke is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
 #
-# Hooke is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Lesser General Public License for more details.
+# Hooke is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
+# Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with Hooke.  If not, see
 """Library for interpreting Hemingway force spectroscopy files.
 """
 
+import os.path
 import numpy
 
 from .. import curve as curve
 from .. import experiment as experiment
-from ..config import Setting
 from ..util.util import Closing as Closing
 from . import Driver as Driver
 
@@ -36,6 +36,8 @@ class HemingwayDriver (Driver):
         super(HemingwayDriver, self).__init__(name='hemingway')
 
     def is_me(self, path):
+        if os.path.isdir(path):
+            return False
         headlines = []
         with Closing(file(path, 'r')) as f:
             for i in range(2):
@@ -53,7 +55,7 @@ class HemingwayDriver (Driver):
                 fields = line.split(':', 1)
                 if len(fields) == 2:
                     file_info[fields[0]] = fields[1]
-            data = numpy.genfromtxt(f, dtype=numpy.float)
+            data = numpy.loadtxt(f, dtype=numpy.float)
         ret = curve.Data(
             shape=data.shape,
             dtype=data.dtype,