From f0288ee2a5623f462418dac238d796994da0b147 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 12 May 2010 13:12:41 -0400 Subject: [PATCH] Removed hooke.liboutlet/.libviewer/.plugin.viewer. Functionality superseded by hooke.ui. --- hooke/liboutlet.py | 85 ---------------------------------------- hooke/libviewer.py | 62 ----------------------------- hooke/plugin/__init__.py | 1 - hooke/plugin/viewer.py | 37 ----------------- 4 files changed, 185 deletions(-) delete mode 100644 hooke/liboutlet.py delete mode 100644 hooke/libviewer.py delete mode 100644 hooke/plugin/viewer.py diff --git a/hooke/liboutlet.py b/hooke/liboutlet.py deleted file mode 100644 index aec7a4c..0000000 --- a/hooke/liboutlet.py +++ /dev/null @@ -1,85 +0,0 @@ -''' -Basic outlet object - -Copyright (C) 2008 Alberto Gomez-Casado (University of Twente). - -This program is released under the GNU General Public License version 2. - -I though of this as just a centralized collector of command output. -Other option would have been making each command save results, but I -think that would have led to a lot of code duplication and probably -huge user hassle (do you want to save this? and this? and this -one?). So there's this object 'outlet' and the only thing each command -has to know about it is the method outlet.push(line) and the format of -that line, that so far is - -type filename [list] - - - type identifies which command produced that line - - filename is the curve from which the command produced the output -(this allows to know for example if a curve had more than one peak, -but user is left responsible of their ordering!). It's also useful to -keep track of where were you last time (if you follow natural order -when looking at curves). - - list can have pretty much anything, depending on the particular -command - -From the point of view of the commands there is nothing else about -outlet. Apart from that I made a couple of commands to delete lines in -case you had a twitch when click and don what that measurement to be -saved and to have a look at current contents of outlet. - -Finally I put in outlet an attribute, relations, that could be used in -the future by the viewers to register themselves so outlet can -trigger their actions when new data arrives (allowing automatic -refreshes). But so far that's probably overdesigning. -''' - -import re - - -class Outlet(object): - - def __init__(self): - self.buffer=[] - #relations is still unused - self.relations=[] - - def push(self, args): - #queue new entry - self.buffer.append(args) - - def pop(self): - #delete last entry - return self.buffer.pop(); - - def printbuf(self): - j=1; - for i in self.buffer: - print j, i - j=j+1 - - def delete(self, number): - #delete entry matching given index - if len(self.buffer)>int(number)-1 and int(number)>0: - self.buffer.pop(int(number)-1) - - def empty(self): - self.buffer=[] - - def read_last(self): - return self.buffer[len(self.buffer)-1] - - def read_first(self): - return self.buffer[0] - - def read_type(self,dtype): - #returns entries matching a given type (force, distance, point...) - aux=[] - index=0 - if dtype=='all': - return self.buffer - for i in self.buffer: - if re.match(dtype+'*',i): - aux.append(i) - return aux diff --git a/hooke/libviewer.py b/hooke/libviewer.py deleted file mode 100644 index f56160d..0000000 --- a/hooke/libviewer.py +++ /dev/null @@ -1,62 +0,0 @@ -''' -Basic Viewer and ascii saver example - -Copyright (C) 2008 Alberto Gomez-Casado (University of Twente). - -This program is released under the GNU General Public License version 2. - -So far outlet is useless. That's where viewers (well, only one now) -do the job. They query outlet for data of some type, process it and -give some elaborated output. Again the only thing they have to know -about outlet is how to call it and the 'line' format. - -I put in the viewer plugin a list to keep them so it is possible to -create many. The basic operations in viewer.py - - vwnew: adds a new viewer to the list, and sets it so it defines -what type of data it will be interested in - - vwaction: tells the viewer to 'do stuff', that is, retrieve data -and process it. Just a wrapper call for the specific one of each -viewer. -''' - -from . import liboutlet as lout -from . import libinput as linput - - -class Viewer(object): - source=[] - data=[] - dtype='all' - action=[] #alias to call the actual viewer function, makes it general - - - def setdtype(self, dt): - #determines wich type of data will be retrieved from outlet - self.dtype=dt - - def show(self): - #TODO should print only data matching 'type' - self.source.printbuf() - - def getdata(self): - #retrieves data from outlet - self.data=self.source.read_type(self.dtype) - - -class Ascii(Viewer): -#example viewer, it just retrieves data and writes it to a text file -#probably this should be in viewer.py? - - def __init__(self,outref): - self.source=outref - #tells the viewer which outlet has the data (so far only one in hooke) - self.action=self.dump - #this allows to call dump (or any other function, depending on the viewer) from the CLI using 'vwaction' - - def dump(self): - #retrieves and saves data - self.getdata() - destination=linput.safeinput('Enter filename:',['results.txt']) - destfile=open(destination,'w+') - destfile.write('\n'.join(self.data)) - destfile.close() diff --git a/hooke/plugin/__init__.py b/hooke/plugin/__init__.py index c8c68ff..5a5954e 100644 --- a/hooke/plugin/__init__.py +++ b/hooke/plugin/__init__.py @@ -33,7 +33,6 @@ PLUGIN_MODULES = [ # ('superimpose', True), ('system', True), # ('tutorial', True), -# ('viewer', True), ] """List of plugin modules and whether they should be included by default. TODO: autodiscovery diff --git a/hooke/plugin/viewer.py b/hooke/plugin/viewer.py deleted file mode 100644 index 43f74ae..0000000 --- a/hooke/plugin/viewer.py +++ /dev/null @@ -1,37 +0,0 @@ -''' -Viewer test case - -Copyright (C) 2008 Alberto Gomez-Casado (University of Twente). - -This program is released under the GNU General Public License version 2. -''' - - -from .. import libviewer as lview -from .. import libinput as linput - -class viewerCommands(object): - - def _plug_init(self): - self.viewerlist=[] - #we keep a list of different viewers so it's possible to retrieve different data - #or process the same data differently - - - def do_vwnew(self,args): - #creates a new viewer - self.viewerlist.append(lview.Ascii(self.outlet)) - dt=linput.safeinput('What type of data will this viewer handle? (force/distance/all)',['force', 'distance', 'all']) - #TODO update types, make a list somewhere? - print dt - self.viewerlist[-1].setdtype(dt) - - - def do_vwaction(self,args): - ''' - triggers default action of viewer number n (default 0) - ''' - - if len(args)==0: - args=0 - self.viewerlist[int(args)].action() -- 2.26.2