[Modeling-cvs] ProjectModeling/Modeling/ModelMasons PyModelMason.py,1.12,1.13
Status: Abandoned
Brought to you by:
sbigaret
From: Sebastien B. <sbi...@us...> - 2004-11-30 17:11:56
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1000/Modeling/ModelMasons Modified Files: PyModelMason.py Log Message: * ModelMasons/PyModelMason.py (PyModelMason.build): added parameter 'pymodel_path', that should be equal to the full path of the file containing the PyModel from which 'model' was built, or None otherwise. If supplied, the method copies the original pymodel into the generated package, otherwise it generates the xml files from the 'model' as usual. Index: PyModelMason.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/PyModelMason.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyModelMason.py 29 Nov 2004 16:47:50 -0000 1.12 --- PyModelMason.py 30 Nov 2004 17:11:46 -0000 1.13 *************** *** 102,106 **** class PyModelMason(ModelMason): "See the module's documentation for details" ! def __init__(self, model, rootPath=None, verbose_mode=0, generation_scheme='compact', fake_mode=0): """ --- 102,106 ---- class PyModelMason(ModelMason): "See the module's documentation for details" ! def __init__(self, model, pymodel_path, rootPath=None, verbose_mode=0, generation_scheme='compact', fake_mode=0): """ *************** *** 108,122 **** supplied model. ! Parameters: ! ! model -- see ModelMason.__init__() ! ! rootPath -- see ModelMason.__init__() ! ! verbode_mode -- see ModelMason.__init__() ! ! use_scheme -- 'compact' or 'base' ! ! fake_mode -- see ModelMason.__init__() """ --- 108,118 ---- supplied model. ! :Parameters: ! - `model`: see ModelMason.__init__() ! - `pymodel_path`: ! - `rootPath`: see ModelMason.__init__() ! - `verbode_mode`: see ModelMason.__init__() ! - `generation_scheme`: either string ``"compact"`` or ``"base"`` ! - `fake_mode`: see ModelMason.__init__() """ *************** *** 131,134 **** --- 127,131 ---- self.generation_scheme=generation_scheme self.base_dir=generation_scheme=='base' and 'MDL' or '' + self.pymodel_path=pymodel_path def tmpl_namespace(self): *************** *** 149,153 **** "-" #----------------------------------------------------------------- ! def create_model_files(self, xml_path, py_path): "Creates or overwrite the model (.xml and .py)" # model_<modelName>.xml --- 146,150 ---- "-" #----------------------------------------------------------------- ! def create_xmlmodel_files(self, xml_path, py_path): "Creates or overwrite the model (.xml and .py)" # model_<modelName>.xml *************** *** 173,176 **** --- 170,185 ---- del modelStr #----------------------------------------------------------------- + def create_pymodel_file(self, pymodel_path_ori, pymodel_path): + "Creates or overwrite the pymodel" + if os.path.exists(pymodel_path): + self.log('Overwriting %s'%pymodel_path) + else: + self.log('Generating %s'%pymodel_path) + if not self.fake_mode: + import shutil + shutil.copy(pymodel_path_ori, pymodel_path) + self.log('... done') + self.log('\n') + #----------------------------------------------------------------- # Build as many directories with __init__.py as needed *************** *** 191,199 **** # COMPACT generation scheme if self.generation_scheme=='compact': ! # Create model files (.xml/.py) ! xmlp=self.fullPathForGeneratedFile('model_'+self.model.name()+'.xml') ! pyp="model_%s.py"%self.model.name() ! create_model_files(self, xmlp, pyp) ! # modules for self._entities in self.entitiesSet(): --- 200,215 ---- # COMPACT generation scheme if self.generation_scheme=='compact': ! if not self.pymodel_path: ! # Create model files (.xml/.py) ! xmlp=self.fullPathForGeneratedFile('model_'+self.model.name()+'.xml') ! pyp="model_%s.py"%self.model.name() ! create_xmlmodel_files(self, xmlp, pyp) ! else: ! basePath=self.fullPathForGeneratedFile(self.base_dir) ! create_pymodel_file(self, ! self.pymodel_path, ! os.path.join(basePath, ! "pymodel_%s.py"%self.model.name())) ! # modules for self._entities in self.entitiesSet(): *************** *** 218,226 **** overwrite=1) ! create_model_files(self, ! os.path.join(basePath, ! 'model_'+self.model.name()+'.xml'), ! os.path.join(self.base_dir, ! "model_%s.py"%self.model.name())) # modules for self._entities in self.entitiesSet(): --- 234,249 ---- overwrite=1) ! if not self.pymodel_path: ! create_xmlmodel_files(self, ! os.path.join(basePath, ! 'model_'+self.model.name()+'.xml'), ! os.path.join(self.base_dir, ! "model_%s.py"%self.model.name())) ! else: ! create_pymodel_file(self, ! self.pymodel_path, ! os.path.join(basePath, ! "pymodel_%s.py"%self.model.name())) ! # modules for self._entities in self.entitiesSet(): |