Ignore:
Timestamp:
Aug 8, 2016 10:09:38 AM (8 years ago)
Author:
lewis
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
9e9f848
Parents:
d6bf064
Message:

Add docstrings & comments, and rename old bsl_loader to otoko_loader

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/file_converter/otoko_loader.py

    r4b862c4 rba65aff  
    1515        self.__dict__.update(kwds) 
    1616 
    17 class BSLParsingError(Exception): 
     17class OTOKOParsingError(Exception): 
    1818    pass 
    1919 
    20 class BSLData: 
     20class OTOKOData: 
    2121    def __init__(self, q_axis, data_axis): 
    2222        self.q_axis = q_axis 
    2323        self.data_axis = data_axis 
    2424 
    25 class BSLLoader(object): 
     25class OTOKOLoader(object): 
    2626 
    2727    def __init__(self, qaxis_path, data_path): 
     
    3636 
    3737        Given the paths of two header files, this function will load each axis in 
    38         turn.  If loading is successfull then an instance of the BSLData class 
     38        turn.  If loading is successfull then an instance of the OTOKOData class 
    3939        will be returned, else an exception will be raised. 
    4040 
     
    5050        data_axis = self._load_bsl_axis(self.data_path) 
    5151 
    52         return BSLData(q_axis, data_axis) 
     52        return OTOKOData(q_axis, data_axis) 
    5353 
    5454    def _load_bsl_axis(self, header_path): 
     
    6060        """ 
    6161        if not os.path.exists(header_path): 
    62             raise BSLParsingError("The header file %s does not exist." % header_path) 
     62            raise OTOKOParsingError("The header file %s does not exist." % header_path) 
    6363 
    6464        binary_file_info_list = [] 
     
    6969            lines = header_file.readlines() 
    7070            if len(lines) < 4: 
    71                 raise BSLParsingError("Expected more lines in %s." % header_path) 
     71                raise OTOKOParsingError("Expected more lines in %s." % header_path) 
    7272 
    7373            info = lines[0] + lines[1] 
     
    8585 
    8686                if len(indicators) != 10: 
    87                     raise BSLParsingError( 
     87                    raise OTOKOParsingError( 
    8888                        "Expected 10 integer indicators on line 3 of %s." \ 
    8989                        % header_path) 
    9090                if not all([i.isdigit() for i in indicators]): 
    91                     raise BSLParsingError( 
     91                    raise OTOKOParsingError( 
    9292                        "Expected all indicators on line 3 of %s to be integers." \ 
    9393                        % header_path) 
     
    115115        all_n_channels = [info.n_channels for info in binary_file_info_list] 
    116116        if not all(all_n_channels[0] == c for c in all_n_channels): 
    117             raise BSLParsingError( 
     117            raise OTOKOParsingError( 
    118118                "Expected all binary files listed in %s to have the same number of channels." % header_path) 
    119119 
     
    123123        for info in binary_file_info_list: 
    124124            if not os.path.exists(info.file_path): 
    125                 raise BSLParsingError( 
     125                raise OTOKOParsingError( 
    126126                    "The data file %s does not exist." % info.file_path) 
    127127 
Note: See TracChangeset for help on using the changeset viewer.