Changeset fd4b6f8 in sasview


Ignore:
Timestamp:
May 25, 2009 4:45:52 PM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
5d98370
Parents:
8068b52
Message:

dataloader: add a method to associate a reader object to an extension type (as opposed to letting the Loader inspect a module).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/loader.py

    r88e289c rfd4b6f8  
    178178        return reader_found 
    179179 
     180    def associate_file_reader(self, ext, loader): 
     181        """ 
     182            Append a reader object to readers 
     183             
     184            @param ext: file extension [string] 
     185            @param module: reader object 
     186        """ 
     187        reader_found = False 
     188         
     189        try: 
     190            # Find supported extensions 
     191            if ext not in self.loaders: 
     192                self.loaders[ext] = [] 
     193            # Append the new reader to the list 
     194            self.loaders[ext].append(loader.read) 
     195 
     196            reader_found = True 
     197             
     198            # Keep track of wildcards 
     199            if hasattr(loader, 'type_name'): 
     200                type_name = loader.type_name 
     201                 
     202                wcard = "%s files (*%s)|*%s" % (type_name, ext.lower(), ext.lower()) 
     203                if wcard not in self.wildcards: 
     204                    self.wildcards.append(wcard) 
     205                  
     206        except: 
     207            logging.error("Loader: Error accessing Reader in %s\n  %s" % (module.__name__, sys.exc_value)) 
     208        return reader_found 
     209 
    180210     
    181211    def _identify_plugin(self, module): 
     
    285315        return self.__registry.associate_file_type(ext, module) 
    286316 
     317    def associate_file_reader(self, ext, loader): 
     318        """ 
     319            Append a reader object to readers 
     320             
     321            @param ext: file extension [string] 
     322            @param module: reader object 
     323        """ 
     324        return self.__registry.associate_file_reader(ext, loader) 
     325 
    287326    def load(self, file, format=None): 
    288327        """ 
Note: See TracChangeset for help on using the changeset viewer.