Changeset bbc8013 in sasview


Ignore:
Timestamp:
Oct 24, 2008 11:36:56 AM (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:
e43c012
Parents:
753552d
Message:

Modify the way default readers are loaded.

Location:
DataLoader
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/__init__.py

    rbb03739 rbbc8013  
    1  
     1from data_info import * 
     2from manipulations import * 
     3from qsmearing import * 
     4from readers import * 
  • DataLoader/loader.py

    r1ed9c57 rbbc8013  
    22    File handler to support different file extensions. 
    33    Uses reflectometry's registry utility. 
     4     
     5    The default readers are found in the 'readers' sub-module 
     6    and registered by default at initialization time. 
     7     
     8    To add a new default reader, one must register it in 
     9    the register_readers method found in readers/__init__.py.  
     10     
     11    A utility method (find_plugins) is available to inspect  
     12    a directory (for instance, a user plug-in directory) and 
     13    look for new readers/writers. 
    414""" 
    515 
     
    2131from zipfile import ZipFile 
    2232 
     33# Default readers are defined in the readers sub-module 
     34import readers 
     35 
    2336class Registry(ExtensionRegistry): 
    2437    """ 
     
    3952        self._created = time.time() 
    4053         
    41         # Find internal readers 
    42         try: 
    43             cwd = os.path.split(__file__)[0] 
    44         except: 
    45             cwd = os.getcwd() 
    46             logging.error("Registry: could not find the installed reader's directory\n %s" % sys.exc_value) 
    47              
    48         dir = os.path.join(cwd, 'readers') 
    49         n = self.find_plugins(dir) 
    50         logging.info("Loader found %i readers" % n) 
     54        # Register default readers 
     55        readers.register_readers(self._identify_plugin) 
    5156         
    5257    def find_plugins(self, dir): 
    5358        """ 
    54             Find readers in a given directory 
     59            Find readers in a given directory. This method 
     60            can be used to inspect user plug-in directories to 
     61            find new readers/writers. 
    5562             
    5663            @param dir: directory to search into 
     
    5865        """ 
    5966        readers_found = 0 
     67         
     68        # Check whether the directory exists 
     69        if not os.path.isdir(dir):  
     70            logging.warning("DataLoader couldn't load from %s" % dir) 
     71            return readers_found 
     72         
    6073        for item in os.listdir(dir): 
    6174            full_path = os.path.join(dir, item) 
  • DataLoader/readers/__init__.py

    rbb03739 rbbc8013  
     1import abs_reader 
     2import cansas_reader 
     3import ascii_reader 
     4import cansas_reader 
     5import danse_reader 
     6import hfir1d_reader 
     7import IgorReader 
     8import tiff_reader 
     9 
     10def register_readers(registry_function): 
     11    """ 
     12        Function called by the registry/loader object to register 
     13        all default readers using a call back function. 
     14     
     15        @param registry_function: function to be called to register each reader 
     16    """ 
     17    registry_function(abs_reader) 
     18    registry_function(cansas_reader) 
     19    registry_function(ascii_reader) 
     20    registry_function(cansas_reader) 
     21    registry_function(danse_reader) 
     22    registry_function(hfir1d_reader) 
     23    registry_function(IgorReader) 
     24    registry_function(tiff_reader) 
     25     
  • DataLoader/test/write_test.xml

    rbee885e rbbc8013  
    11<?xml version="1.0" ?> 
    2 <SASroot version="1.0"> 
     2<SASroot version="1.0" xmlns="cansas1d/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="cansas1d/1.0 http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd"> 
    33        <SASentry> 
    44                <Title> 
    55                        Test title 
    66                </Title> 
    7                 <Run name="run name"> 
     7                <Run> 
    88                        1234 
    99                </Run> 
Note: See TracChangeset for help on using the changeset viewer.