Ignore:
Timestamp:
May 3, 2012 11:23:15 AM (13 years ago)
Author:
Jae Cho <jhjcho@…>
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:
56acb5d
Parents:
74d7b59
Message:

set all the custom model names same as its filename

File:
1 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/src/sans/perspectives/calculator/model_editor.py

    r41a8cb3 r316e231  
    324324            elif line.count("self.description = '%s'"): 
    325325                out_f.write(line % description + "\n") 
    326             elif line.count("self.name = '%s'"): 
    327                 out_f.write(line % name + "\n") 
     326            #elif line.count("self.name = '%s'"): 
     327            #    out_f.write(line % name + "\n") 
    328328            else: 
    329329                out_f.write(line + "\n") 
     
    690690                if has_scipy: 
    691691                    out_f.write("import scipy" + "\n") 
    692             elif line.count("name = "): 
    693                 out_f.write(line % self.name + "\n") 
     692            #elif line.count("name = "): 
     693            #    out_f.write(line % self.name + "\n") 
    694694            elif line: 
    695695                out_f.write(line + "\n") 
     
    777777from sans.models.pluginmodel import Model1DPlugin 
    778778from math import * 
     779import os 
     780import sys 
    779781import numpy 
    780782#import scipy? 
    781783class Model(Model1DPlugin): 
    782     name = "%s"                              
     784    name = ""                              
    783785    def __init__(self): 
    784         Model1DPlugin.__init__(self, name=self.name)                                                      
     786        Model1DPlugin.__init__(self, name=self.name)   
     787        #set name same as file name  
     788        self.name = self.get_fname()                                                    
    785789        #self.params here 
    786790        self.description = "%s" 
     
    827831""" 
    828832TEST_TEMPLATE = """ 
     833    def get_fname(self): 
     834        path = sys._getframe().f_code.co_filename 
     835        basename  = os.path.basename(path) 
     836        name, _ = os.path.splitext(basename) 
     837        return name 
    829838###################################################################### 
    830839## THIS IS FOR TEST. DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
     
    854863#P2_model:  
    855864from sans.models.%s import %s as P2 
     865import os 
     866import sys 
    856867 
    857868class Model(Model1DPlugin): 
     
    863874        ## Setting  model name model description 
    864875        self.description = '%s' 
    865         self.name = '%s' 
     876        self.name = self.get_fname() 
    866877        if self.name.rstrip().lstrip() == '': 
    867878            self.name = self._get_name(p_model1.name, p_model2.name) 
     
    11181129( p_model1.name, p_model2.name ) 
    11191130        self.description += description 
    1120          
     1131           
     1132    def get_fname(self): 
     1133        path = sys._getframe().f_code.co_filename 
     1134        basename  = os.path.basename(path) 
     1135        name, _ = os.path.splitext(basename) 
     1136        return name      
     1137            
    11211138if __name__ == "__main__":  
    11221139    m1= Model()  
Note: See TracChangeset for help on using the changeset viewer.