Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/models.py

    re92a352 r05b8e01  
    1818from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 
    1919from sasmodels.sasview_model import load_custom_model, load_standard_models 
     20from sas.sasgui.perspectives.fitting.fitpage import CUSTOM_MODEL 
    2021 
    2122 
     
    2324PLUGIN_LOG = os.path.join(os.path.expanduser("~"), '.sasview', PLUGIN_DIR, 
    2425                          "plugins.log") 
     26PLUGIN_NAME_BASE = '[plug-in] ' 
    2527 
    2628def get_model_python_path(): 
     
    181183            try: 
    182184                model = load_custom_model(path) 
    183                 model.name = "[plug-in] "+model.name 
     185                model.name = PLUGIN_NAME_BASE + model.name 
    184186                plugins[model.name] = model 
    185187            except Exception: 
     
    259261        temp = {} 
    260262        if self.is_changed(): 
    261             return  _findModels(dir) 
     263            temp =  _findModels(dir) 
     264            self.last_time_dir_modified = time.time() 
     265            return temp 
    262266        logging.info("plugin model : %s" % str(temp)) 
    263267        return temp 
     
    306310        if os.path.isdir(plugin_dir): 
    307311            temp = os.path.getmtime(plugin_dir) 
    308             if  self.last_time_dir_modified != temp: 
     312            if  self.last_time_dir_modified < temp: 
    309313                is_modified = True 
    310314                self.last_time_dir_modified = temp 
     
    317321        new models were added else return empty dictionary 
    318322        """ 
     323        self.plugins = [] 
    319324        new_plugins = self.findModels() 
    320         if len(new_plugins) > 0: 
    321             for name, plug in  new_plugins.iteritems(): 
    322                 if name not in self.stored_plugins.keys(): 
    323                     self.stored_plugins[name] = plug 
    324                     self.plugins.append(plug) 
    325                     self.model_dictionary[name] = plug 
    326             self.model_combobox.set_list("Plugin Models", self.plugins) 
     325        if new_plugins: 
     326            for name, plug in  new_plugins.items(): 
     327                self.stored_plugins[name] = plug 
     328                self.plugins.append(plug) 
     329                self.model_dictionary[name] = plug 
     330            self.model_combobox.set_list(CUSTOM_MODEL, self.plugins) 
    327331            return self.model_combobox.get_list() 
    328332        else: 
Note: See TracChangeset for help on using the changeset viewer.