Changeset ca3f89b in sasview for src/sas/sascalc/dataloader/readers


Ignore:
Timestamp:
Sep 15, 2016 8:33:57 AM (8 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
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
Children:
73e0427
Parents:
69d8aac
git-author:
Jeff Krzywon <krzywon@…> (09/01/16 14:36:07)
git-committer:
Piotr Rozyczko <rozyczko@…> (09/15/16 08:33:57)
Message:

Resolves #644 and #642: Improved loading performance for cansas XML data. Loading invariants and fits from save states no longer throw errors or open multiple windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    r4baf505 rca3f89b  
    6262    type_name = "canSAS" 
    6363    invalid = True 
     64    frm = "" 
    6465    ## Log messages and errors 
    6566    logging = None 
     
    138139                    for entry in entry_list: 
    139140                        # Create a new DataInfo object for every <SASentry> 
    140  
    141141 
    142142                        # Set the file name and then parse the entry. 
     
    183183        return self.output 
    184184 
    185     def _parse_entry(self, dom): 
     185    def _parse_entry(self, dom, recurse=False): 
    186186        """ 
    187187        Parse a SASEntry - new recursive method for parsing the dom of 
     
    192192        """ 
    193193 
    194         frm = inspect.stack()[1] 
    195         if not self._is_call_local(frm): 
     194        if not self._is_call_local() and not recurse: 
    196195            self.reset_state() 
    197196            self.add_data_set() 
     
    201200        self.base_ns = "{0}{1}{2}".format("{", \ 
    202201                            CANSAS_NS.get(self.cansas_version).get("ns"), "}") 
    203         tagname = '' 
    204         tagname_original = '' 
    205202 
    206203        # Go through each child in the parent element 
     
    225222                    self._initialize_new_data_set() 
    226223                ## Recursion step to access data within the group 
    227                 self._parse_entry(node) 
     224                self._parse_entry(node, True) 
    228225                if tagname == "SASsample": 
    229226                    self.current_datainfo.sample.name = name 
     
    437434                length = len(self.names) - 1 
    438435            self.parent_class = self.names[length] 
    439         if not self._is_call_local(frm): 
     436        if not self._is_call_local() and not recurse: 
     437            self.frm = "" 
    440438            self.add_data_set() 
    441439            empty = None 
     
    448446 
    449447 
    450     def _is_call_local(self, frm=""): 
    451         """ 
    452  
    453         :return: 
    454         """ 
    455         if frm == "": 
    456             frm = inspect.stack()[1] 
    457         mod_name = frm[1].replace("\\", "/").replace(".pyc", "") 
     448    def _is_call_local(self): 
     449        """ 
     450 
     451        """ 
     452        if self.frm == "": 
     453            inter = inspect.stack() 
     454            self.frm = inter[2] 
     455        mod_name = self.frm[1].replace("\\", "/").replace(".pyc", "") 
    458456        mod_name = mod_name.replace(".py", "") 
    459457        mod = mod_name.split("sas/") 
     
    836834        # If the calling function was not the cansas reader, return a minidom 
    837835        #      object rather than an lxml object. 
    838         frm = inspect.stack()[1] 
    839         doc, entry_node = self._check_origin(entry_node, doc, frm) 
     836        self.frm = inspect.stack()[1] 
     837        doc, entry_node = self._check_origin(entry_node, doc) 
    840838        return doc, entry_node 
    841839 
     
    12321230                self.append(node, entry_node) 
    12331231 
    1234     def _check_origin(self, entry_node, doc, frm): 
     1232    def _check_origin(self, entry_node, doc): 
    12351233        """ 
    12361234        Return the document, and the SASentry node associated with 
     
    12421240        :param doc: entire xml tree 
    12431241        """ 
    1244         if not frm: 
    1245             frm = inspect.stack()[1] 
    1246         mod_name = frm[1].replace("\\", "/").replace(".pyc", "") 
     1242        if not self.frm: 
     1243            self.frm = inspect.stack()[1] 
     1244        mod_name = self.frm[1].replace("\\", "/").replace(".pyc", "") 
    12471245        mod_name = mod_name.replace(".py", "") 
    12481246        mod = mod_name.split("sas/") 
Note: See TracChangeset for help on using the changeset viewer.