Changeset 1b0b3ca in sasview
- Timestamp:
- Jul 7, 2008 6:39:06 PM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 9a3adab
- Parents:
- cf3b781
- Location:
- DataLoader
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/docs/todo.txt
r672c44da r1b0b3ca 13 13 - Document all classes and methods, and all inputs and outputs. 14 14 - Where are the comments for log() going? That should be documented in the code. 15 - Why is the description of the DataLoader module in setup.py "Python module for fitting"?15 [changed]- Why is the description of the DataLoader module in setup.py "Python module for fitting"? 16 16 - The return object of a load seems to be inconsistent and depend only on the particular reader. This will cause problems since 17 17 the calling modules will be unable to know what to expect. An interface should be defined. -
DataLoader/loader.py
ra916ccc r1b0b3ca 23 23 path = [os.path.abspath(dir)] 24 24 file = None 25 25 #print "in findplugings",path 26 26 try: 27 27 (file, path, info) = imp.find_module(name, path) … … 41 41 pass 42 42 return plugins 43 class SingleLoader(object):43 class Loader(object): 44 44 45 45 __load = None 46 print "hello" 47 class Loader(object): 46 class Load(object): 48 47 49 48 def __init__(self): 50 49 self.readers = {} 51 50 self.reading=None 52 print "in loader" 51 self.__setitem__() 52 #print "in loader",self.readers 53 53 54 54 def __setitem__(self, ext=None, reader=None): 55 if reader==None and ext==None: 55 import os 56 if reader==None and ext==None:#1st load 56 57 plugReader=None 57 58 if os.path.isdir('plugins'): 59 #print "plugreader in pluging",plugReader 58 60 plugReader=_findReaders('plugins')# import all module in plugins 59 elif os.path.isdir('../plugins'): 61 if os.path.isdir('../plugins'): 62 #print "plugreader in Dataloader pluging",plugReader 60 63 plugReader=_findReaders('../plugins') 64 else: 65 if os.path.isdir('..\DataLoader\plugins'): 66 os.chdir(os.path.abspath('..\DataLoader\plugins'))# change the current 67 #directory to dataLoader\plugins 68 plugReader=_findReaders('plugins') 69 61 70 if plugReader !=None: 62 71 for preader in plugReader:# for each modules takes list of extensions 63 #printpreader.ext72 print preader,preader.ext 64 73 for item in preader.ext: 65 74 ext=item … … 67 76 self.readers[ext] = [] 68 77 self.readers[ext].insert(0,preader) 78 79 #print "plugreader",plugReader 80 #print "In setitem",self.readers 69 81 elif reader !=None and ext !=None: 70 82 if ext not in self.readers: … … 110 122 idx = file.find('.') 111 123 ext = file[idx:] if idx >= 0 else '' 124 #print "exten",ext 125 #print self.readers 112 126 try: 113 127 return self.readers[ext] … … 127 141 May raise a loader-defined exception if loader fails. 128 142 """ 143 try: 144 #print "in load",os.path.abspath(path) 145 os.path.isfile( os.path.abspath(path)) 146 #print "went here in load check path" 147 except: 148 raise ValueError," file doesn't exist" 129 149 if format is None: 130 150 readers = self.lookup(path) … … 132 152 readers = self.readers[format] 133 153 if readers!=None: 154 134 155 for fn in readers: 135 156 try: 157 #print "path",os.getcwd( ) 136 158 value=fn.read(path) 137 159 self.reading= fn.__class__ … … 142 164 """ Create singleton instance """ 143 165 # Check whether we already have an instance 144 if SingleLoader.__load is None:166 if Loader.__load is None: 145 167 # Create and remember instance 146 SingleLoader.__load = SingleLoader.Loader()147 SingleLoader.__load.__setitem__()168 Loader.__load = Loader.Load() 169 Loader.__load.__setitem__() 148 170 # Store instance reference as the only member in the handle 149 self.__dict__['_ SingleLoader__load'] = SingleLoader.__load171 self.__dict__['_Loader__load'] = Loader.__load 150 172 151 173 def __getattr__(self, attr): … … 156 178 """ Delegate access to implementation """ 157 179 return setattr(self.__load, attr, value) 158 159 if __name__=="__main__":160 l = SingleLoader()161 print l162 print "look up",l.lookup('angles_flat.png')163 print l.__getitem__('.tiff')164 #print l.__contains__('.tiff')165 d=SingleLoader()166 print d.__getitem__('.tiff') -
DataLoader/readers/TXT2_Reader.py
rc125e0c r1b0b3ca 7 7 should be able to read only 2 columns of data 8 8 """ 9 9 ext=['.txt','.dat'] 10 10 def _init_(self,x=None,y=None,dx=None,dy=None): 11 11 # variable to store loaded values … … 14 14 self.dx = dx 15 15 self.dy = dy 16 16 17 17 def read(self,path, format=None): 18 18 """ Store the values loaded from file in local variables """ 19 19 if not path == None: 20 20 read_it = False 21 ext=['.txt','.dat']22 for item in ext:21 22 for item in self.ext: 23 23 if path.lower().find(item)>=0: 24 24 read_it = True -
DataLoader/readers/TXT3_Reader.py
rc125e0c r1b0b3ca 6 6 This class is loading values from given file or value giving by the user 7 7 """ 8 8 ext=['.txt','.dat'] 9 9 def _init_(self,filename=None,x=None,y=None,dx=None,dy=None): 10 10 # variable to store loaded values … … 23 23 if not path == None: 24 24 read_it = False 25 ext=['.txt','.dat']26 for item in ext:25 26 for item in self.ext: 27 27 if path.lower().find(item)>=0: 28 28 read_it = True -
DataLoader/setup.py
rbb03739 r1b0b3ca 10 10 name="DataLoader", 11 11 version = "0.1", 12 description = "Python module for fitting",12 description = "Python module for loading", 13 13 author = "University of Tennessee", 14 14 #author_email = "", -
DataLoader/test/testLoad.py
r14226f4 r1b0b3ca 6 6 import math 7 7 import DataLoader 8 from DataLoader.loader import SingleLoader8 from DataLoader.loader import Loader 9 9 from DataLoader.readers import TXT3_Reader,TXT2_Reader 10 10 from DataLoader.readers import IgorReader,danse_reader,tiff_reader 11 11 import os.path 12 12 class testLoader(unittest.TestCase): 13 14 13 15 """ test fitting """ 14 16 #Creating a loader 15 L= SingleLoader()17 L=Loader() 16 18 17 19 #creating readers … … 98 100 self.assertEqual(data.__class__,tiff_reader.ReaderInfo) 99 101 self.assertEqual(self.L.getAcTReader('angles_flat.png'),self.read5.__class__) 100 def testplugin(self): 101 """ test loading with plugging""" 102 l=SingleLoader() 103 self.assertEqual(l.__contains__('.tiff'),True) 104 self.assertEqual(l.__contains__('.png'),True) 105 self.assertEqual(self.L.getAcTReader('angles_flat.png'),tiff_reader.Reader) 106 self.assertEqual(self.L.load('angles_flat.png').__class__,tiff_reader.ReaderInfo) 107 102 103
Note: See TracChangeset
for help on using the changeset viewer.