Changeset 2d1b700 in sasview for sansmodels/src/python_wrapper
- Timestamp:
- Jan 5, 2012 10:52:13 AM (13 years ago)
- 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:
- dd60b45
- Parents:
- 7ffa8196
- Location:
- sansmodels/src/python_wrapper
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/python_wrapper/WrapperGenerator.py
rd62f422 r2d1b700 56 56 """ 57 57 58 def __init__(self, filename ):58 def __init__(self, filename, output_dir='.'): 59 59 """ Initialization """ 60 60 … … 90 90 ## parameters with orientation 91 91 self.orientation_params =[] 92 ## output directory for wrappers 93 self.output_dir = output_dir 92 94 93 95 … … 289 291 The file is written in C[PYTHONCLASS].c 290 292 """ 291 292 file = open("C"+self.pythonClass+'.cpp', 'w') 293 template = open("classTemplate.txt", 'r') 293 file_path = os.path.join(self.output_dir, "C"+self.pythonClass+'.cpp') 294 file = open(file_path, 'w') 295 296 template = open(os.path.join(os.path.dirname(__file__), "classTemplate.txt"), 'r') 294 297 295 298 tmp_buf = template.read() … … 414 417 The file is written in ../[PYTHONCLASS].py 415 418 """ 416 417 file = open( "../sans/models/"+self.pythonClass+'.py', 'w')418 template = open( "modelTemplate.txt", 'r')419 file_path = os.path.join(self.output_dir, "../sans/models/"+self.pythonClass+'.py') 420 file = open(file_path, 'w') 421 template = open(os.path.join(os.path.dirname(__file__), "modelTemplate.txt"), 'r') 419 422 420 423 tmp_buf = template.read() -
sansmodels/src/python_wrapper/wrapping.py
r67424cd r2d1b700 4 4 from WrapperGenerator import WrapperGenerator 5 5 6 def generate_wrappers(header_dir, output_dir='.'): 7 nModels=0 8 for item in os.listdir(header_dir): 9 toks = os.path.splitext(os.path.basename(item)) 10 if toks[1]=='.h': 11 nModels += 1 12 name = toks[0] 13 app = WrapperGenerator(os.path.join(header_dir, name+".h"), output_dir=output_dir) 14 app.read() 15 app.write_c_wrapper() 16 app.write_python_wrapper() 17 #print app 18 print "Total number of model wrappers created is %s" % nModels 6 19 7 header_dir = os.path.join('..', 'c_extensions') 20 if __name__ == '__main__': 21 header_dir = os.path.join('..', 'c_extensions') 22 generate_wrappers(header_dir) 8 23 9 nModels=0 10 for item in os.listdir(header_dir): 11 toks = os.path.splitext(os.path.basename(item)) 12 if toks[1]=='.h': 13 nModels += 1 14 name = toks[0] 15 app = WrapperGenerator(os.path.join(header_dir, name+".h")) 16 app.read() 17 app.write_c_wrapper() 18 app.write_python_wrapper() 19 print app 20 print "Number total of models is %s" % nModels 24
Note: See TracChangeset
for help on using the changeset viewer.