X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=hooke%2Fdriver%2F__init__.py;h=8704f5d58cfa072bf77938f1590144bc06d18307;hb=0d1e91fbf2d28c915ed84b11be135d09d4665d51;hp=beaa991da4d41296b1c2a75c3f19cf7bafb061a9;hpb=856eda3d709682ec4bea3aa4e5588423065e2dd6;p=hooke.git diff --git a/hooke/driver/__init__.py b/hooke/driver/__init__.py index beaa991..8704f5d 100644 --- a/hooke/driver/__init__.py +++ b/hooke/driver/__init__.py @@ -1,3 +1,21 @@ +# Copyright (C) 2010 W. Trevor King +# +# 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 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 +# . + """The driver module provides :class:`Driver`\s for identifying and reading data files. @@ -6,20 +24,24 @@ commercial force spectroscopy microscopes are provided, and it's easy to write your own to handle your lab's specific format. """ +import logging +import os.path + from ..config import Setting -from ..plugin import construct_graph, IsSubclass +from ..util.pluggable import IsSubclass, construct_graph + DRIVER_MODULES = [ # ('csvdriver', True), # ('hdf5', True), -# ('hemingclamp', True), -# ('jpk', True), + ('hemingway', True), + ('jpk', True), # ('mcs', True), # ('mfp1dexport', True), -# ('mfp3d', True), -# ('picoforce', True), -# ('picoforcealt', True), + ('mfp3d', True), + ('picoforce', True), ('tutorial', True), + ('wtk', True), ] """List of driver modules and whether they should be included by default. TODO: autodiscovery @@ -30,10 +52,10 @@ DRIVER_SETTING_SECTION = 'drivers' """ -class Driver(object): +class Driver (object): """Base class for file format drivers. - :attr:`name` identifies your driver, and should match the module + :attr:`name` identifies your driver and should match the module name. """ def __init__(self, name): @@ -60,16 +82,20 @@ class Driver(object): """ return False - def read(self, path): + def read(self, path, info=None): """Read data from `path` and return a - (:class:`hooke.curve.Data`, `info`) tuple. + ([:class:`hooke.curve.Data`, ...], `info`) tuple. - The `info` :class:`dict` must contain values for the keys: - 'filetype' and 'experiment'. See :class:`hooke.curve.Curve` - for details. + The input `info` :class:`dict` may contain attributes read + from the :class:`~hooke.playlist.FilePlaylist`. + + See :class:`hooke.curve.Curve` for details. """ raise NotImplementedError + def logger(self): + return logging.getLogger('hooke') + # Construct driver dependency graph and load default drivers. DRIVER_GRAPH = construct_graph( @@ -90,7 +116,8 @@ def default_settings(): settings.append(Setting( section=DRIVER_SETTING_SECTION, option=driver.name, - value=str(default_include), + value=default_include, + type='bool', help=help, )) for dnode in DRIVER_GRAPH: