[Modeling-cvs] ProjectModeling/Modeling/scripts mdl_generate_python_code.py,1.9,1.10
Status: Abandoned
Brought to you by:
sbigaret
From: Sebastien B. <sbi...@us...> - 2004-11-30 17:14:34
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2174/Modeling/scripts Modified Files: mdl_generate_python_code.py Log Message: Script mdl_generate_python_code.py now detects whether it is called with an xml- or a py-model and, in case it is called w/ a pymodel, it copies it into the generated module (it was previously only generating the files for the xml-model, no matter how it was called) Index: mdl_generate_python_code.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/scripts/mdl_generate_python_code.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** mdl_generate_python_code.py 22 Sep 2004 18:56:31 -0000 1.9 --- mdl_generate_python_code.py 30 Nov 2004 17:14:25 -0000 1.10 *************** *** 44,68 **** del tb ! def build_python_code(model, generation_scheme, rootPath=None, typeOfCode='python', verbose_mode=0, fake_mode=0): """ Builds the python-code templates for the supplied model ! Parameters ! ! model -- an instance of Modeling.Model ! ! generation_scheme -- ! ! rootPath -- where the files should be dropped ! ! typeOfCode -- (do not use) only 'python' is available for the moment ; ! future dev. will probably include generation of zope products. ! ! verbose_mode -- if set to true, the building process logs some informational message onto sys.stderr while building the files. Default is false. ! ! fake_mode -- if true, do not create or change any file, just report what would be done --- 44,63 ---- del tb ! def build_python_code(model, pymodel_path, generation_scheme, rootPath=None, typeOfCode='python', verbose_mode=0, fake_mode=0): """ Builds the python-code templates for the supplied model ! :Parameters: ! - `model`: an instance of Modeling.Model ! - `pymodel_path`: the detected type, as returned by `Model._loadModel()` ! - `generation_scheme`: ! - `rootPath`: where the files should be dropped ! - `typeOfCode`: (do not use) only 'python' is available for the moment ; ! future dev. will probably include generation of zope products. ! - `verbose_mode`: if set to true, the building process logs some informational message onto sys.stderr while building the files. Default is false. ! - `fake_mode`: if true, do not create or change any file, just report what would be done *************** *** 76,80 **** if typeOfCode=='python': from Modeling.ModelMasons.PyModelMason import PyModelMason ! mason = PyModelMason(model, rootPath, verbose_mode=verbose_mode, generation_scheme=generation_scheme, fake_mode=fake_mode) --- 71,76 ---- if typeOfCode=='python': from Modeling.ModelMasons.PyModelMason import PyModelMason ! mason = PyModelMason(model, pymodel_path, rootPath, ! verbose_mode=verbose_mode, generation_scheme=generation_scheme, fake_mode=fake_mode) *************** *** 161,164 **** --- 157,161 ---- model_file=args[0] rootPath=len(args)==2 and args[1] or './' + pymodel_path=None # load the model *************** *** 166,170 **** try: from Modeling import Model ! model=Model.loadModel(model_file) if not model: raise RuntimeError, "Abnormal: got no exception but Model is None" --- 163,170 ---- try: from Modeling import Model ! model,model_type=Model._loadModel(model_file) ! if model_type=="pymodel": ! import os ! pymodel_path=os.path.abspath(model_file) if not model: raise RuntimeError, "Abnormal: got no exception but Model is None" *************** *** 189,194 **** try: ! build_python_code(model, generation_scheme, rootPath, verbose_mode=verbose, ! fake_mode=fake_mode) except TargetDirectoryAlreadyExists, exc: sys.stderr.write(str(sys.exc_info()[1])+'\n') --- 189,194 ---- try: ! build_python_code(model, pymodel_path, generation_scheme, rootPath, ! verbose_mode=verbose, fake_mode=fake_mode) except TargetDirectoryAlreadyExists, exc: sys.stderr.write(str(sys.exc_info()[1])+'\n') |