Changeset d3619421 in sasview
- Timestamp:
- Jul 10, 2008 11:12:37 AM (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:
- 85bf28c
- Parents:
- c45976b
- Location:
- DataLoader
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/loader.py
rc45976b rd3619421 10 10 logging.basicConfig(level=logging.ERROR, 11 11 format='%(asctime)s %(levelname)s %(message)s', 12 filename=' loader_log.txt',12 filename='test_log.txt', 13 13 filemode='w') 14 14 … … 85 85 plugin reader. 86 86 if an extension is not specified and a reader does not contain a field 87 ext , a ValueError "missing extension" is raised.87 ext , a warning is printed in test_log.txt file. 88 88 @note: when called without parameters __setitem__ will try to load 89 89 readers inside a "readers" directory … … 92 92 """ 93 93 if dir==None: 94 dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),'readers') 94 dir = 'readers' 95 dir=os.path.join(os.path.dirname(os.path.abspath(__file__)),dir) 95 96 96 97 if (reader==None and ext==None) or dir:#1st load … … 100 101 if os.path.isdir('../'+dir): 101 102 plugReader=_findReaders('../'+dir) 102 else: 103 if os.path.isdir('../DataLoader/'+dir): 104 os.chdir(os.path.abspath('../DataLoader/'+dir))# change the current 105 plugReader=_findReaders(dir) 106 103 104 107 105 if plugReader !=None: 106 list=[] 108 107 for preader in plugReader:# for each modules takes list of extensions 109 108 try: 110 109 list=preader.ext 111 except: 112 raise AttributeError," %s instance has no attribute 'ext'"\ 113 %(preader.__class__) 114 for item in list: 115 ext=item 116 if ext not in self.readers:#assign extension with its reader 117 self.readers[ext] = [] 118 self.readers[ext].insert(0,preader) 110 except AttributeError,msg: 111 logging.warning(msg) 112 pass 113 #raise AttributeError," %s instance has no attribute 'ext'"\ 114 #%(preader.__class__) 115 if list !=[]: 116 for item in list: 117 ext=item 118 if ext not in self.readers:#assign extension with its reader 119 self.readers[ext] = [] 120 self.readers[ext].insert(0,preader) 119 121 #Reader and extension are given 120 122 elif reader !=None and ext !=None: … … 182 184 return self.readers[ext] 183 185 except: 184 186 logging.warning("Unknown file type '%s'"%ext) 185 187 raise RuntimeError, "Unknown file type '%s'"%ext 186 188 -
DataLoader/test/testLoad.py
r8d6440f rd3619421 21 21 import os.path 22 22 class testLoader(unittest.TestCase): 23 23 logging.debug("Inside testLoad module") 24 24 25 25 """ test fitting """ -
DataLoader/test/testplugings.py
r94daf8a rd3619421 11 11 import os.path 12 12 import os 13 import logging 14 logging.basicConfig(level=logging.DEBUG, 15 format='%(asctime)s %(levelname)s %(message)s', 16 filename='test_log.txt', 17 filemode='w') 13 18 class testLoader(unittest.TestCase): 14 L=Loader() 19 20 try:L=Loader() 21 except AttributeError,msg: 22 logging.warning(msg) 15 23 def testplugin(self): 16 24 """ test loading with readers""" … … 19 27 self.assertEqual(self.L.__contains__('.png'),True) 20 28 self.assertEqual(self.L.__contains__('.txt'),True) 29 #tested corrupted file.asc 30 try:self.L.load('MAR07232_rest.ASC') 31 except AttributeError,msg: 32 #logging.log(10,str(msg)) 33 logging.warning(str(msg)) 21 34 def testplugin1(self): 22 35 """ test loading with plugging"""
Note: See TracChangeset
for help on using the changeset viewer.