From cd7b8ff4687547d3661c23180d7145d4ccc898ae Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 4 May 2010 02:41:19 -0400 Subject: [PATCH] Added modular directory structure. Also some import and other cleanups to convince myself that the reorganization was mostly working. --- CHANGELOG | 0 bin/hooke | 5 +++ conf/hooke.conf | 56 ++++++++++++++++++++++++------- conf/macro.conf | 6 ++++ doc/USAGE | 6 ++-- doc/hooke.jpg | Bin hooke/__init__.py | 0 hooke/driver/__init__.py | 0 hooke/driver/csvdriver.py | 4 +-- hooke/driver/hemingclamp.py | 2 +- hooke/driver/jpk.py | 2 +- hooke/driver/mcs.py | 4 +-- hooke/driver/mfp1dexport.py | 4 +-- hooke/driver/picoforce.py | 2 +- hooke/driver/picoforcealt.py | 2 +- hooke/driver/tutorialdriver.py | 2 +- hooke/hooke.py | 59 +++++++++++++++++---------------- hooke/hooke_cli.py | 30 +++++++---------- hooke/libhooke.py | 45 ++++++++++++++----------- hooke/libhookecurve.py | 4 +-- hooke/libviewer.py | 4 +-- hooke/plugin/__init__.py | 0 hooke/plugin/autopeak.py | 3 +- hooke/plugin/fit.py | 4 ++- hooke/plugin/flatfilts.py | 20 ++++------- hooke/plugin/generalclamp.py | 7 ++-- hooke/plugin/generalvclamp.py | 2 +- hooke/plugin/macro.py | 7 ++-- hooke/plugin/massanalysis.py | 9 +++-- hooke/plugin/multidistance.py | 3 +- hooke/plugin/pcluster.py | 22 ++++-------- hooke/plugin/procplots.py | 6 ++-- hooke/plugin/superimpose.py | 6 ++-- hooke/plugin/tutorial.py | 4 +-- hooke/plugin/viewer.py | 4 +-- hooke/test/default.000 | 0 hooke/test/test.hkp | 2 +- 37 files changed, 186 insertions(+), 150 deletions(-) mode change 100755 => 100644 CHANGELOG create mode 100755 bin/hooke mode change 100755 => 100644 conf/hooke.conf create mode 100644 conf/macro.conf mode change 100755 => 100644 doc/hooke.jpg create mode 100644 hooke/__init__.py create mode 100644 hooke/driver/__init__.py mode change 100755 => 100644 hooke/driver/hemingclamp.py mode change 100755 => 100644 hooke/driver/picoforce.py mode change 100755 => 100644 hooke/hooke.py mode change 100755 => 100644 hooke/hooke_cli.py mode change 100755 => 100644 hooke/libhooke.py mode change 100755 => 100644 hooke/libhookecurve.py create mode 100644 hooke/plugin/__init__.py mode change 100755 => 100644 hooke/plugin/fit.py mode change 100755 => 100644 hooke/plugin/flatfilts.py mode change 100755 => 100644 hooke/plugin/procplots.py mode change 100755 => 100644 hooke/plugin/tutorial.py mode change 100755 => 100644 hooke/test/default.000 diff --git a/CHANGELOG b/CHANGELOG old mode 100755 new mode 100644 diff --git a/bin/hooke b/bin/hooke new file mode 100755 index 0000000..5a57baa --- /dev/null +++ b/bin/hooke @@ -0,0 +1,5 @@ +#!/usr/bin/python + +import hooke.hooke + +hooke.hooke.main() diff --git a/conf/hooke.conf b/conf/hooke.conf old mode 100755 new mode 100644 index 75a31f9..c1d8d7b --- a/conf/hooke.conf +++ b/conf/hooke.conf @@ -1,26 +1,59 @@ - - - - - insert directory - + + + + + ./doc/ + + + + + + --> - test.hkp + ./hooke/test/test.hkp + --> @@ -69,4 +102,3 @@ and -IMPORTANTLY- their order. - diff --git a/conf/macro.conf b/conf/macro.conf new file mode 100644 index 0000000..b197e36 --- /dev/null +++ b/conf/macro.conf @@ -0,0 +1,6 @@ + + + + + + diff --git a/doc/USAGE b/doc/USAGE index 785f47d..eed629a 100644 --- a/doc/USAGE +++ b/doc/USAGE @@ -2,9 +2,9 @@ Starting Hooke ============== Open a terminal, go to the directory Hooke is installed and type -python hooke/hooke.py (You may need to give the full path for Python -on Windows systems). If everything is OK, Hooke displays a nice -splashscreen and starts. + python bin/hooke +(You may need to give the full path for Python on Windows systems). +If everything is OK, Hooke displays a nice splashscreen and starts. Once Hooke is launched from the terminal window, you see a text like the following: diff --git a/doc/hooke.jpg b/doc/hooke.jpg old mode 100755 new mode 100644 diff --git a/hooke/__init__.py b/hooke/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hooke/driver/__init__.py b/hooke/driver/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hooke/driver/csvdriver.py b/hooke/driver/csvdriver.py index fb465ee..1d05e23 100644 --- a/hooke/driver/csvdriver.py +++ b/hooke/driver/csvdriver.py @@ -12,8 +12,8 @@ If the number of columns is odd, the last column is ignored. (c)Massimo Sandal, 2008 ''' -import libhookecurve as lhc -import libhooke as lh +from .. import libhookecurve as lhc +from .. import libhooke as lh import csv class csvdriverDriver(lhc.Driver): diff --git a/hooke/driver/hemingclamp.py b/hooke/driver/hemingclamp.py old mode 100755 new mode 100644 index 41e721a..3145404 --- a/hooke/driver/hemingclamp.py +++ b/hooke/driver/hemingclamp.py @@ -14,7 +14,7 @@ __changelog__=''' 2007_02_07: Initial implementation ''' import string -import libhookecurve as lhc +from .. import libhookecurve as lhc class DataChunk(list): '''Dummy class to provide ext and ret methods to the data list. diff --git a/hooke/driver/jpk.py b/hooke/driver/jpk.py index 5fd5f5d..090b09a 100644 --- a/hooke/driver/jpk.py +++ b/hooke/driver/jpk.py @@ -1,5 +1,5 @@ import string -import libhookecurve as lhc +from .. import libhookecurve as lhc class DataChunk(list): #Dummy class to provide ext and ret methods to the data list. diff --git a/hooke/driver/mcs.py b/hooke/driver/mcs.py index 48836f2..6562d90 100644 --- a/hooke/driver/mcs.py +++ b/hooke/driver/mcs.py @@ -6,8 +6,8 @@ driver for mcs fluorescence files Massimo Sandal, Allen Chen (c) 2009 ''' -import libhookecurve as lhc -import libhooke as lh +from .. import libhookecurve as lhc +from .. import libhooke as lh import struct class mcsDriver(lhc.Driver): diff --git a/hooke/driver/mfp1dexport.py b/hooke/driver/mfp1dexport.py index 5cc18e5..37af7df 100644 --- a/hooke/driver/mfp1dexport.py +++ b/hooke/driver/mfp1dexport.py @@ -6,8 +6,8 @@ Driver for text-exported MFP 1D files Massimo Sandal (c) 2009 ''' -import libhookecurve as lhc -import libhooke as lh +from .. import libhookecurve as lhc +from .. import libhooke as lh class mfp1dexportDriver(lhc.Driver): diff --git a/hooke/driver/picoforce.py b/hooke/driver/picoforce.py old mode 100755 new mode 100644 index e7df889..c60e57c --- a/hooke/driver/picoforce.py +++ b/hooke/driver/picoforce.py @@ -11,7 +11,7 @@ This program is released under the GNU General Public License version 2. import re, struct from scipy import arange -import libhookecurve as lhc +from .. import libhookecurve as lhc __version__='0.0.0.20080404' diff --git a/hooke/driver/picoforcealt.py b/hooke/driver/picoforcealt.py index ec69118..836fb45 100644 --- a/hooke/driver/picoforcealt.py +++ b/hooke/driver/picoforcealt.py @@ -12,7 +12,7 @@ This program is released under the GNU General Public License version 2. import re, struct from scipy import arange -import libhookecurve as lhc +from .. import libhookecurve as lhc __version__='0.0.0.20081706' diff --git a/hooke/driver/tutorialdriver.py b/hooke/driver/tutorialdriver.py index 9d38c47..8644eef 100644 --- a/hooke/driver/tutorialdriver.py +++ b/hooke/driver/tutorialdriver.py @@ -45,7 +45,7 @@ END that is, two plots with two datasets each. ''' -import libhookecurve as lhc #We need to import this library to define some essential data types +from .. import libhookecurve as lhc #We need to import this library to define some essential data types class tutorialdriverDriver(lhc.Driver): ''' diff --git a/hooke/hooke.py b/hooke/hooke.py old mode 100755 new mode 100644 index 55f23b1..75cc7d9 --- a/hooke/hooke.py +++ b/hooke/hooke.py @@ -10,8 +10,7 @@ Copyright (C) 2008 Massimo Sandal (University of Bologna, Italy). This program is released under the GNU General Public License version 2. ''' -from libhooke import HOOKE_VERSION -from libhooke import WX_GOOD +from .libhooke import HOOKE_VERSION, WX_GOOD import os @@ -24,12 +23,12 @@ from wx.lib.newevent import NewEvent import matplotlib.numerix as nx import scipy as sp -from threading import * +from threading import Thread import Queue -from hooke_cli import HookeCli -from libhooke import * -import libhookecurve as lhc +from .hooke_cli import HookeCli +from .libhooke import HookeConfig, ClickedPoint +from . import libhookecurve as lhc #import file versions, just to know with what we're working... from hooke_cli import __version__ as hookecli_version @@ -64,15 +63,20 @@ plugin_commands_namespaces=[] plugin_gui_namespaces=[] for plugin_name in config['plugins']: try: - plugin=__import__(plugin_name) + hooke_module=__import__('hooke.plugin.'+plugin_name) + plugin = getattr(hooke_module.plugin, plugin_name) try: - eval('CLI_PLUGINS.append(plugin.'+plugin_name+'Commands)') #take Command plugin classes - plugin_commands_namespaces.append(dir(eval('plugin.'+plugin_name+'Commands'))) + #take Command plugin classes + commands = getattr(plugin, plugin_name+'Commands') + CLI_PLUGINS.append(commands) + plugin_commands_namespaces.append(dir(commands)) except: pass try: - eval('GUI_PLUGINS.append(plugin.'+plugin_name+'Gui)') #take Gui plugin classes - plugin_gui_namespaces.append(dir(eval('plugin.'+plugin_name+'Gui'))) + #take Gui plugin classes + gui = getattr(plugin, plugin_name+'Gui') + GUI_PLUGINS.append(gui) + plugin_gui_namespaces.append(dir(gui)) except: pass except ImportError: @@ -82,8 +86,11 @@ for plugin_name in config['plugins']: print 'Imported plugin ',plugin_name #eliminate names common to all namespaces -for i in range(len(plugin_commands_namespaces)): - plugin_commands_namespaces[i]=[item for item in plugin_commands_namespaces[i] if (item != '__doc__' and item != '__module__' and item != '_plug_init')] +for i,namespace in enumerate(plugin_commands_namespaces): + plugin_commands_namespaces[i] = \ + filter(lambda item : not (item.startswith('__') + or item == '_plug_init'), + namespace) #check for conflicts in namespaces between plugins #FIXME: only in commands now, because I don't have Gui plugins to check #FIXME: how to check for plugin-defined variables (self.stuff) ?? @@ -94,7 +101,8 @@ for namespace,plugin_name in zip(plugin_commands_namespaces, config['plugins']): for item in namespace: if item in plugin_commands_names: i=plugin_commands_names.index(item) #we exploit the fact index gives the *first* occurrence of a name... - print 'Error. Plugin ',plugin_name,' defines a function already defined by ',whatplugin_defines[i],'!' + print 'Error. Plugin %s defines a function %s already defined by %s!' \ + % (plugin_name, item, whatplugin_defines[i]) print 'This should not happen. Please disable one or both plugins and contact the plugin authors to solve the conflict.' print 'Hooke cannot continue.' exit() @@ -110,9 +118,10 @@ FILE_DRIVERS=[] LOADED_DRIVERS=[] for driver_name in config['drivers']: try: - driver=__import__(driver_name) + hooke_module=__import__('hooke.driver.'+driver_name) + driver = getattr(hooke_module.driver, driver_name) try: - eval('FILE_DRIVERS.append(driver.'+driver_name+'Driver)') + FILE_DRIVERS.append(getattr(driver, driver_name+'Driver')) except: pass except ImportError: @@ -353,7 +362,8 @@ class MainWindow(wx.Frame): #make sure we execute _plug_init() for every command line plugin we import for plugin_name in config['plugins']: try: - plugin=__import__(plugin_name) + hooke_module=__import__('hooke.plugin.'+plugin_name) + plugin = getattr(hooke_module.plugin, plugin_name) try: eval('plugin.'+plugin_name+'Gui._plug_init(self)') pass @@ -760,7 +770,9 @@ class MySplashScreen(wx.SplashScreen): # This is a recipe to a the screen. # Modify the following variables as necessary. #aBitmap = wx.Image(name = "wxPyWiki.jpg").ConvertToBitmap() - aBitmap=wx.Image(name='hooke.jpg').ConvertToBitmap() + aBitmap=wx.Image(name=os.path.join( + config['install']['docpath'], + 'hooke.jpg')).ConvertToBitmap() splashStyle = wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT splashDuration = 2000 # milliseconds splashCallback = None @@ -783,16 +795,6 @@ class MySplashScreen(wx.SplashScreen): #------------------------------------------------------------------------------ def main(): - - #save the directory where Hooke is located - config['hookedir']=os.getcwd() - - #now change to the working directory. - try: - os.chdir(config['workdir']) - except OSError: - print "Warning: Invalid work directory." - app=wx.PySimpleApp() def make_gui_class(*bases): @@ -808,7 +810,6 @@ def main(): my_cmdline=CliThread(main_frame, list_of_events) my_cmdline.start() - app.MainLoop() if __name__ == '__main__': diff --git a/hooke/hooke_cli.py b/hooke/hooke_cli.py old mode 100755 new mode 100644 index fc0cee3..886563b --- a/hooke/hooke_cli.py +++ b/hooke/hooke_cli.py @@ -10,14 +10,7 @@ Copyright (C) 2006 Massimo Sandal (University of Bologna, Italy). This program is released under the GNU General Public License version 2. ''' -from libhooke import * #FIXME -import libhookecurve as lhc - -import libinput as linp -import liboutlet as lout - -from libhooke import WX_GOOD -from libhooke import HOOKE_VERSION +from .libhooke import HOOKE_VERSION, WX_GOOD import wxversion wxversion.select(WX_GOOD) @@ -47,17 +40,19 @@ from numpy import __version__ as numpy_version from sys import version as python_version import platform +from .libhooke import PlaylistXML +from . import libhookecurve as lhc +from . import libinput as linp +from . import liboutlet as lout + -class HookeCli(cmd.Cmd): +class HookeCli(cmd.Cmd, object): def __init__(self,frame,list_of_events,events_from_gui,config,drivers): cmd.Cmd.__init__(self) self.prompt = 'hooke: ' - - self.current_list=[] #the playlist we're using - self.current=None #the current curve under analysis. self.plots=None ''' @@ -71,8 +66,6 @@ class HookeCli(cmd.Cmd): then undergoes modifications by the plotmanip modifier functions. The modified plot is saved in self.plots and used if needed by other functions. ''' - - self.pointer=0 #a pointer to navigate the current list #Things that come from outside @@ -239,10 +232,11 @@ Syntax: loadlist [playlist file] self.current_list, self.playlist_generics=playxml.load(play_to_load) self.current_playxml=playxml except IOError: - print 'File not found.' + print 'File not found.', play_to_load return - print 'Loaded %s curves' %len(self.current_list) + print 'Loaded %s curves from %s' \ + % (len(self.current_list), play_to_load) if 'pointer' in self.playlist_generics.keys(): self.pointer=int(self.playlist_generics['pointer']) @@ -514,8 +508,8 @@ Plots the current force curve Syntax: plot ''' def do_plot(self,args): - - self.current.identify(self.drivers) + if self.current.identify(self.drivers) == False: + return self.plots=self.current.curve.default_plots() try: self.plots=self.current.curve.default_plots() diff --git a/hooke/libhooke.py b/hooke/libhooke.py old mode 100755 new mode 100644 index 73534f2..05c9837 --- a/hooke/libhooke.py +++ b/hooke/libhooke.py @@ -10,8 +10,6 @@ With algorithms contributed by Francesco Musiani (University of Bologna, Italy) This program is released under the GNU General Public License version 2. ''' -import libhookecurve as lhc - import scipy import numpy import xml.dom.minidom @@ -20,6 +18,8 @@ import os.path import string import csv +from . import libhookecurve as lhc + HOOKE_VERSION=['0.8.3_devel', 'Seinei', '2008-04-16'] WX_GOOD=['2.6','2.8'] @@ -106,8 +106,13 @@ class PlaylistXML(object): new_playlist=[] for myfile in list_of_files: #rebuild a data structure from the xml attributes - the_curve=lhc.HookeCurve(myfile.getAttribute('path')) - for attribute in myfile.attributes.keys(): #extract attributes for the single curve + the_curve=lhc.HookeCurve( + os.path.join(os.path.dirname(self.playpath), + myfile.getAttribute('path'))) + for attribute in myfile.attributes.keys(): + #extract attributes for the single curve + if attribute == 'path': + continue # we already added this attribute the_curve.__dict__[attribute]=myfile.getAttribute(attribute) new_playlist.append(the_curve) @@ -129,6 +134,11 @@ class PlaylistXML(object): self.playlist.writexml(outfile,indent='\n') outfile.close() +def config_file_path(filename, config_dir=None): + if config_dir == None: + config_dir = os.path.abspath( + os.path.join(os.path.dirname(os.path.dirname(__file__)), 'conf')) + return os.path.join(config_dir, filename) class HookeConfig(object): ''' @@ -142,18 +152,14 @@ class HookeConfig(object): def __init__(self, config_dir=None): self.config={} + self.config['install']={} self.config['plugins']=[] self.config['drivers']=[] self.config['plotmanips']=[] self.config_dir = config_dir - if self.config_dir == None: - self.config_dir = os.path.abspath( - os.path.join(os.path.dirname(os.path.dirname(__file__)), - 'conf')) def load_config(self, filename): - print 'loading config file', os.path.join(self.config_dir, filename) - myconfig=file(os.path.join(self.config_dir, filename)) + myconfig=file(config_file_path(filename, config_dir=self.config_dir)) #the following 3 lines are needed to strip newlines. otherwise, since newlines #are XML elements too, the parser would read them (and re-save them, multiplying @@ -175,19 +181,27 @@ class HookeConfig(object): return rc def handleConfig(config): + install_elements=config.getElementsByTagName("install") display_elements=config.getElementsByTagName("display") plugins_elements=config.getElementsByTagName("plugins") drivers_elements=config.getElementsByTagName("drivers") - workdir_elements=config.getElementsByTagName("workdir") defaultlist_elements=config.getElementsByTagName("defaultlist") plotmanip_elements=config.getElementsByTagName("plotmanips") + handleInstall(install_elements) handleDisplay(display_elements) handlePlugins(plugins_elements) handleDrivers(drivers_elements) - handleWorkdir(workdir_elements) handleDefaultlist(defaultlist_elements) handlePlotmanip(plotmanip_elements) + def handleInstall(install_elements): + for install in install_elements: + for node in install.childNodes: + if node.nodeType == node.TEXT_NODE: + continue + path = os.path.abspath(getText(node.childNodes).strip()) + self.config['install'][str(node.tagName)] = path + def handleDisplay(display_elements): for element in display_elements: for attribute in element.attributes.keys(): @@ -214,13 +228,6 @@ class HookeConfig(object): except: #if we allow fancy formatting of xml, there is a text node, so tagName fails for it... pass - def handleWorkdir(workdir): - ''' - default working directory - ''' - wdir=getText(workdir[0].childNodes) - self.config['workdir']=wdir.strip() - def handleDefaultlist(defaultlist): ''' default playlist diff --git a/hooke/libhookecurve.py b/hooke/libhookecurve.py old mode 100755 new mode 100644 index 0bb4a49..44dc9d6 --- a/hooke/libhookecurve.py +++ b/hooke/libhookecurve.py @@ -15,10 +15,8 @@ class HookeCurve(object): #bring on all the driver, with his load of methods etc. #so we can access the whole of it. self.curve=tempcurve - del tempcurve return True - - print 'Not a recognizable curve format.' + print 'Not a recognizable curve format: ', self.path return False diff --git a/hooke/libviewer.py b/hooke/libviewer.py index 5397a6e..f56160d 100644 --- a/hooke/libviewer.py +++ b/hooke/libviewer.py @@ -19,8 +19,8 @@ and process it. Just a wrapper call for the specific one of each viewer. ''' -import liboutlet as lout -import libinput as linput +from . import liboutlet as lout +from . import libinput as linput class Viewer(object): diff --git a/hooke/plugin/__init__.py b/hooke/plugin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hooke/plugin/autopeak.py b/hooke/plugin/autopeak.py index 17a30ed..bbea952 100644 --- a/hooke/plugin/autopeak.py +++ b/hooke/plugin/autopeak.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from libhooke import WX_GOOD, ClickedPoint +from hooke.libhooke import WX_GOOD, ClickedPoint + import wxversion wxversion.select(WX_GOOD) from wx import PostEvent diff --git a/hooke/plugin/fit.py b/hooke/plugin/fit.py old mode 100755 new mode 100644 index 7ab6037..4b6ba7d --- a/hooke/plugin/fit.py +++ b/hooke/plugin/fit.py @@ -7,13 +7,15 @@ Licensed under the GNU GPL version 2 Non-standard Dependencies: procplots.py (plot processing plugin) ''' -from libhooke import WX_GOOD, ClickedPoint +from hooke.libhooke import WX_GOOD, ClickedPoint + import wxversion wxversion.select(WX_GOOD) #from wx import PostEvent #from wx.lib.newevent import NewEvent import scipy import scipy.odr +import scipy.stats import numpy as np import copy import Queue diff --git a/hooke/plugin/flatfilts.py b/hooke/plugin/flatfilts.py old mode 100755 new mode 100644 index 09dc3db..47eab59 --- a/hooke/plugin/flatfilts.py +++ b/hooke/plugin/flatfilts.py @@ -7,21 +7,20 @@ Licensed under the GNU LGPL version 2 Other plugin dependencies: procplots.py (plot processing plugin) ''' -from libhooke import WX_GOOD + +from hooke.libhooke import WX_GOOD + import wxversion wxversion.select(WX_GOOD) - import xml.dom.minidom - import wx import scipy import numpy from numpy import diff - #import pickle -import libpeakspot as lps -import libhookecurve as lhc +from .. import libpeakspot as lps +from .. import libhookecurve as lhc class flatfiltsCommands(object): @@ -29,14 +28,7 @@ class flatfiltsCommands(object): def _plug_init(self): #configurate convfilt variables convfilt_configurator=ConvfiltConfig() - - #different OSes have different path conventions - if self.config['hookedir'][0]=='/': - slash='/' #a Unix or Unix-like system - else: - slash='\\' #it's a drive letter, we assume it's Windows - - self.convfilt_config=convfilt_configurator.load_config(self.config['hookedir']+slash+'convfilt.conf') + self.convfilt_config=convfilt_configurator.load_config('convfilt.conf') def do_flatfilt(self,args): ''' diff --git a/hooke/plugin/generalclamp.py b/hooke/plugin/generalclamp.py index e3c6fe1..2777f49 100644 --- a/hooke/plugin/generalclamp.py +++ b/hooke/plugin/generalclamp.py @@ -3,12 +3,15 @@ GENERALCLAMP.py Plugin regarding general force clamp measurements ''' -from libhooke import WX_GOOD, ClickedPoint +from hooke.libhooke import WX_GOOD, ClickedPoint + import wxversion -import libhookecurve as lhc wxversion.select(WX_GOOD) from wx import PostEvent +from .. import libhookecurve as lhc + + class generalclampCommands(object): def plotmanip_clamp(self, plot, current, customvalue=False): diff --git a/hooke/plugin/generalvclamp.py b/hooke/plugin/generalvclamp.py index 2813150..45cfa2c 100644 --- a/hooke/plugin/generalvclamp.py +++ b/hooke/plugin/generalvclamp.py @@ -4,7 +4,7 @@ generalvclamp.py Plugin regarding general velocity clamp measurements ''' -from libhooke import WX_GOOD, ClickedPoint +from hooke.libhooke import WX_GOOD, ClickedPoint import wxversion wxversion.select(WX_GOOD) from wx import PostEvent diff --git a/hooke/plugin/macro.py b/hooke/plugin/macro.py index 88d13a5..2a1ca99 100644 --- a/hooke/plugin/macro.py +++ b/hooke/plugin/macro.py @@ -5,17 +5,18 @@ Records, saves and executes batches of commands (c)Alberto Gomez-Casado 2008 ''' -import libhookecurve as lhc -import libinput as linput import os.path import string +from .. import libhookecurve as lhc +from .. import libinput as linput + class macroCommands(object): currentmacro=[] pause=0 auxprompt=[] - macrodir=[] + macrodir=None def _plug_init(self): diff --git a/hooke/plugin/massanalysis.py b/hooke/plugin/massanalysis.py index 0a36657..a9ea615 100644 --- a/hooke/plugin/massanalysis.py +++ b/hooke/plugin/massanalysis.py @@ -8,14 +8,13 @@ libpeakspot.py flatfilts.py ''' - -import libpeakspot as lps -import libhookecurve as lhc -import libhooke as lh import numpy as np - import csv +from .. import libpeakspot as lps +from .. import libhookecurve as lhc +from .. import libhooke as lh + class massanalysisCommands(object): def _plug_init(self): diff --git a/hooke/plugin/multidistance.py b/hooke/plugin/multidistance.py index 517a286..9db5f5d 100644 --- a/hooke/plugin/multidistance.py +++ b/hooke/plugin/multidistance.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -from libhooke import WX_GOOD, ClickedPoint +from hooke.libhooke import WX_GOOD, ClickedPoint + import wxversion wxversion.select(WX_GOOD) from wx import PostEvent diff --git a/hooke/plugin/pcluster.py b/hooke/plugin/pcluster.py index 2e16620..eb1770a 100644 --- a/hooke/plugin/pcluster.py +++ b/hooke/plugin/pcluster.py @@ -1,5 +1,6 @@ +from ..libhooke import WX_GOOD, ClickedPoint, config_file_path + from mdp import pca -from libhooke import WX_GOOD, ClickedPoint import wxversion wxversion.select(WX_GOOD) from wx import PostEvent @@ -8,9 +9,11 @@ import scipy as sp import copy import os.path import time -import libhookecurve as lhc import pylab as pyl +from .. import libhookecurve as lhc + + import warnings warnings.simplefilter('ignore',np.RankWarning) @@ -28,13 +31,9 @@ class pclusterCommands(object): Automatically measures peaks and extracts informations for further clustering (c)Paolo Pancaldi, Massimo Sandal 2009 ''' - if self.config['hookedir'][0]=='/': - slash='/' #a Unix or Unix-like system - else: - slash='\\' blindw = str(self.convfilt_config['blindwindow']) pclus_dir = "pCluster_blind"+blindw+"_"+time.strftime("%Y%m%d_%H%M") - self.my_work_dir = os.getcwd()+slash+pclus_dir+slash + self.my_work_dir = os.path.join(os.getcwd(), pclus_dir) self.my_curr_dir = os.path.basename(os.getcwd()) os.mkdir(self.my_work_dir) @@ -343,14 +342,7 @@ class pclusterCommands(object): ''' # reads the columns of pca - if self.config['hookedir'][0]=='/': - slash='/' #a Unix or Unix-like system - else: - slash='\\' - self.my_hooke_dir = self.config['hookedir']+slash - #self.my_work_dir = os.getcwd()+slash+"pCluster_"+time.strftime("%Y%m%d_%H%M")+slash - #self.my_curr_dir = os.path.basename(os.getcwd()) - conf=open(self.my_hooke_dir+"pca_config.txt") + conf=open(config_file_path("pca_config.txt"), 'r') config = conf.readlines() conf.close() diff --git a/hooke/plugin/procplots.py b/hooke/plugin/procplots.py old mode 100755 new mode 100644 index 612ae0b..b8baa15 --- a/hooke/plugin/procplots.py +++ b/hooke/plugin/procplots.py @@ -4,17 +4,19 @@ Processed plots plugin for force curves. Licensed under the GNU GPL version 2 ''' -from libhooke import WX_GOOD +from ..libhooke import WX_GOOD import wxversion wxversion.select(WX_GOOD) import wx -import libhookecurve as lhc import numpy as np import scipy as sp import scipy.signal import copy +from .. import libhookecurve as lhc + + class procplotsCommands(object): def _plug_init(self): diff --git a/hooke/plugin/superimpose.py b/hooke/plugin/superimpose.py index 41083f6..448ded3 100644 --- a/hooke/plugin/superimpose.py +++ b/hooke/plugin/superimpose.py @@ -1,11 +1,11 @@ -from libhooke import WX_GOOD +from ..libhooke import WX_GOOD import wxversion wxversion.select(WX_GOOD) from wx import PostEvent - -import libhookecurve as lhc from numpy import arange, mean +from .. import libhookecurve as lhc + class superimposeCommands(object): def _plug_init(self): diff --git a/hooke/plugin/tutorial.py b/hooke/plugin/tutorial.py old mode 100755 new mode 100644 index 50a0d78..61461f6 --- a/hooke/plugin/tutorial.py +++ b/hooke/plugin/tutorial.py @@ -6,10 +6,10 @@ internals. (c)Massimo Sandal 2007 ''' -import libhookecurve as lhc - import numpy as np +from .. import libhookecurve as lhc + ''' SYNTAX OF DATA TYPE DECLARATION: type = type of object diff --git a/hooke/plugin/viewer.py b/hooke/plugin/viewer.py index 7a6881d..43f74ae 100644 --- a/hooke/plugin/viewer.py +++ b/hooke/plugin/viewer.py @@ -7,8 +7,8 @@ This program is released under the GNU General Public License version 2. ''' -import libviewer as lview -import libinput as linput +from .. import libviewer as lview +from .. import libinput as linput class viewerCommands(object): diff --git a/hooke/test/default.000 b/hooke/test/default.000 old mode 100755 new mode 100644 diff --git a/hooke/test/test.hkp b/hooke/test/test.hkp index da648f4..883d597 100644 --- a/hooke/test/test.hkp +++ b/hooke/test/test.hkp @@ -2,4 +2,4 @@ - \ No newline at end of file + -- 2.26.2