Changeset 73b1c72 in sasview for DataLoader


Ignore:
Timestamp:
Jul 3, 2008 8:32:59 AM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
14226f4
Parents:
87bff18
Message:

modified but working on singleton

Location:
DataLoader
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/loader.py

    r87bff18 r73b1c72  
    99import logging 
    1010import os.path 
     11 
     12 
    1113def _findReaders(dir): 
    1214    # List of plugin objects 
     
    8688        self.readers = {} 
    8789        self.reading=None 
     90        self.dir='plugins' 
     91        self.__setitem__() 
    8892         
    89          
     93    def set_pluginDir (self,path): 
     94        """ specify the name of folder containing pluging""" 
     95        if not os.path.isdir(path): 
     96            os.mkdir(path) 
     97        self.dir=path 
    9098    def __setitem__(self, ext=None, reader=None): 
    9199        if reader==None: 
    92100            plugReader=None 
    93             if os.path.isdir('plugins'): 
    94                 plugReader=_findReaders('plugins')# import all module in plugins 
    95             elif os.path.isdir('../plugins'): 
    96                 plugReader=_findReaders('../plugins') 
     101            if os.path.isdir(self.dir): 
     102                plugReader=_findReaders(self.dir)# import all module in plugins 
     103            elif os.path.isdir('../'+self.dir): 
     104                plugReader=_findReaders('../'+self.dir) 
    97105            if plugReader !=None: 
    98106                for preader in plugReader:# for each modules takes list of extensions 
     
    135143    def lookup(self, path): 
    136144        """ 
    137         Return the loader associated with the file type of path. 
     145        Return the reader associated with the file type of path. 
    138146        """         
    139147        file = os.path.basename(path) 
     
    148156                 
    149157    def getAcTReader(self,path): 
     158        """ return  Reader  actually reading""" 
    150159        return self.reading 
    151160     
     
    171180if __name__=="__main__": 
    172181    l=Loader() 
    173     l.__setitem__() 
    174182    print "look up",l.lookup('angles_flat.png') 
    175183    print l.__getitem__('.tiff') 
     184    print l.__getitem__('jpeg') 
    176185    print l.__contains__('.tiff') 
    177186     
  • DataLoader/readers/tiff_reader.py

    rbb03739 r73b1c72  
    4343    type = [] 
    4444    ## Extension 
    45     ext  = ['tif', 'jpg', 'png', 'jpeg', 'tiff', 'gif', 'bmp']     
     45    ext  = ['tif', 'jpg', '.png', 'jpeg', '.tiff', 'gif', 'bmp']     
    4646         
    4747    def read(self, filename=None): 
  • DataLoader/test/testLoad.py

    r96510c8 r73b1c72  
    101101        """ test loading with plugging""" 
    102102        l=Loader() 
    103         l.__setitem__() 
    104103        self.assertEqual(l.__contains__('.tiff'),True) 
    105104        self.assertEqual(l.__contains__('.png'),True) 
Note: See TracChangeset for help on using the changeset viewer.