Thread: [Modeling-cvs] ProjectModeling/Modeling/ModelMasons PyModelMason.py,1.8,1.8.2.1
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-04-21 22:53:09
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons In directory sc8-pr-cvs1:/tmp/cvs-serv6229a/ModelMasons Modified Files: Tag: brch-0_9pre6-1-ModelMasons_base_generation_scheme PyModelMason.py Log Message: Added the 'MDL' sub-directory containing the files that are overwritten when mdl_generate_python_code.py (option: -B) regenerates a package First proposal. TODO: check the constraint for option -B: a package cannot be generated from a model where a class and at least one of its (direct or indirect) subclasses leave in the same module. Index: PyModelMason.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/PyModelMason.py,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** PyModelMason.py 20 Apr 2003 16:10:39 -0000 1.8 --- PyModelMason.py 21 Apr 2003 22:53:05 -0000 1.8.2.1 *************** *** 40,44 **** from Cheetah.Template import Template ! from Python_bricks import init,model,base_module,module_base,module_compact,setup_tmpl class PyModelMason(ModelMason): --- 40,44 ---- from Cheetah.Template import Template ! from Python_bricks import init,init_base,model,base_module,module_base,module_compact,setup_tmpl class PyModelMason(ModelMason): *************** *** 68,71 **** --- 68,72 ---- self._entities=[] # used during build self.generation_scheme=generation_scheme + self.base_dir=generation_scheme=='base' and 'MDL' or '' def tmpl_namespace(self): *************** *** 77,80 **** --- 78,83 ---- 'model' : self.model, 'entities': self._entities, + 'base_dir': self.base_dir, + 'entitiesSet': self.entitiesSet, } return nameSpace *************** *** 83,86 **** --- 86,107 ---- def build(self): "-" + #----------------------------------------------------------------- + def create_model_files(self, xml_path, py_path): + # model_<modelName>.xml + self.log('Generating %s... '%xml_path) + self.model.saveModelAsXMLFile(xml_path) + self.log('done\n') + + # model_<modelName>.py + xml=open(xml_path) + modelStr=xml.read() + xml.close() + self.createFileFromTemplate(model.model(), + py_path, + namespace={'model_str':modelStr}, + overwrite=1) + del modelStr + #----------------------------------------------------------------- + # Build as many directories with __init__.py as needed self.build_package() *************** *** 93,113 **** self.createEmptyFile("DEPENDENCIES.txt",overwrite=0) - # model_<modelName>.xml - modelFileName='model_'+self.model.name()+'.xml' - modelFileName=self.fullPathForGeneratedFile(modelFileName) - self.log('Generating %s... '%modelFileName) - self.model.saveModelAsXMLFile(modelFileName) - self.log('done\n') - - # model_<modelName>.py - xml=open(modelFileName) - modelStr=xml.read() - xml.close() - self.createFileFromTemplate(model.model(), - "model_%s.py"%self.model.name(), - namespace={'model_str':modelStr}, - overwrite=1) - del modelStr - # package's __init__.py self.createFileFromTemplate(init.init(),"__init__.py",overwrite=0) --- 114,117 ---- *************** *** 117,120 **** --- 121,129 ---- # 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(): *************** *** 126,137 **** # BASE generation scheme elif self.generation_scheme=='base': ! # create 'Base' ! #basePath=self.fullPathForGeneratedFile('Base') ! #self.log("Creating directory %s... "%basePath) ! #try: ! # os.mkdir(basePath) ! #except: self.log('no\n') ! #else: self.log('ok\n') ! # modules for self._entities in self.entitiesSet(): --- 135,154 ---- # BASE generation scheme elif self.generation_scheme=='base': ! # create 'Base' and model files (.xml/.py) ! basePath=self.fullPathForGeneratedFile(self.base_dir) ! self.log("Creating directory %s... "%basePath) ! try: ! os.mkdir(basePath) ! except: self.log('no\n') ! else: self.log('ok\n') ! self.createFileFromTemplate(init_base.init_base(), ! os.path.join(self.base_dir,"__init__.py"), ! overwrite=0) ! ! 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(): *************** *** 141,144 **** overwrite=0) self.createFileFromTemplate(base_module.base_module(), ! "%sBase.py" % module_name, overwrite=1) --- 158,162 ---- overwrite=0) self.createFileFromTemplate(base_module.base_module(), ! os.path.join(self.base_dir, ! "%s.py" % module_name), overwrite=1) |