From: LUCIE BERTHON Date: Fri, 7 Sep 2018 08:48:07 +0000 (+0200) Subject: Ajout du writer XML surchargeant le save X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d73c53c51401ff9ba19b4ebb499e8f094adab0a;p=tools%2Feficas.git Ajout du writer XML surchargeant le save --- diff --git a/MapIdentification/cata_map_cl0d.py b/MapIdentification/cata_map_cl0d.py index 35f78a5b..9071a2ef 100644 --- a/MapIdentification/cata_map_cl0d.py +++ b/MapIdentification/cata_map_cl0d.py @@ -56,8 +56,7 @@ MAP_input_file = PROC(nom = 'MAP_input_file', #----------------------------------- constitutive_law_parameters_status = SIMP(statut='o', typ='TXM', into=['Existing', 'New'], - #defaut='New' - ), + ), #----------------------------------- b_constitutive_law_parameters_existing = BLOC( condition="constitutive_law_parameters_status == 'Existing'", @@ -85,7 +84,7 @@ MAP_input_file = PROC(nom = 'MAP_input_file', os.getenv('TFELHOME'), "share/mfront/tests", "behaviours"), - ), + ), #----------------------------------- exp_filename_list_status = SIMP(statut='o', typ='TXM', diff --git a/MapIdentification/cata_map_cl0d_param.py b/MapIdentification/cata_map_cl0d_param.py index 8dfa63cf..2f670944 100644 --- a/MapIdentification/cata_map_cl0d_param.py +++ b/MapIdentification/cata_map_cl0d_param.py @@ -57,12 +57,12 @@ def F_Parameters(statut) : return FACT( ) -Parameters_list = PROC(nom = 'List of material parameters', +Parameters_list = PROC(nom = 'Parameters_list', #----------------------------------- MAP_Version = SIMP(statut='o', typ='TXM', defaut=getVersion()), #----------------------------------- - parameters = F_Parameters(statut='o') + Parameters = F_Parameters(statut='o') ) TEXTE_NEW_JDC = 'Parameters_list()' diff --git a/MapIdentification/mesScripts_MAPIDENTIFICATION.py b/MapIdentification/mesScripts_MAPIDENTIFICATION.py index a1bbdd6a..50e490d9 100644 --- a/MapIdentification/mesScripts_MAPIDENTIFICATION.py +++ b/MapIdentification/mesScripts_MAPIDENTIFICATION.py @@ -1,21 +1,24 @@ import re import os -def comm2MAPinput(input_filename): - # Saving my input file by converting comm file into ini - with open(input_filename) as input_file: - lines = input_file.readlines() +from ConfigParser import SafeConfigParser, NoOptionError, RawConfigParser - string = "[C_solver_constitutive_law0d]\n" - keys =["output_directory", +MAP_KEYS =["output_directory", "constitutive_law_formulation", "constitutive_law_parameters", "user_defined_mfront_file_directory", "exp_filename_list", "mtest_options", "interface"] + +def comm2MAPinput(input_filename): + # Saving my input file by converting comm file into ini + with open(input_filename) as input_file: + lines = input_file.readlines() + + string = "[c_solver_constitutive_law0d]\n" for line in lines: - for key in keys: + for key in KEYS: if key + "=" in line: string += key + "=" + line.split("'")[1] + "\n" @@ -26,8 +29,22 @@ def comm2MAPinput(input_filename): return output_filename + +def writeMAPinput(dictValeur): + """ + """ + config = RawConfigParser() + + config.add_section("c_solver_constitutive_law0d") + for key, value in dictValeur.iteritems(): + if key in KEYS: + config.set("c_solver_constitutive_law0d", key, value) + with open("toto.input",'w') as f_out : + config.write(f_out) + def run(editor): print ('je rentre dans run') + print editor.fichier command_file = "/home/C41270/MAPinput_test.comm" # TODO: nom en dur command_file = comm2MAPinput(command_file) diff --git a/MapIdentification/prefs_MapIdentification.py b/MapIdentification/prefs_MapIdentification.py index 0eec5d7a..a0869136 100644 --- a/MapIdentification/prefs_MapIdentification.py +++ b/MapIdentification/prefs_MapIdentification.py @@ -37,8 +37,8 @@ encoding='iso-8859-1' #typeDeCata='XML' catalogues=( ('MapIdentification','MAP file',os.path.join(repIni,'cata_map_cl0d.py'),'MapIdentification','python'), - ('MapIdentification','Experiences plan',os.path.join(repIni,'cata_map_cl0d_exp.py'),'python','python'), - ('MapIdentification','Material parameters',os.path.join(repIni,'cata_map_cl0d_param.py'),'python','python'), + ('MapIdentification','Experiences plan',os.path.join(repIni,'cata_map_cl0d_exp.py'),'MapIdentificationTMP','python'), + ('MapIdentification','Material parameters',os.path.join(repIni,'cata_map_cl0d_param.py'),'MapIdentificationTMP','python'), ) catalogues_exp=( diff --git a/generator/generator_MapIdentification.py b/generator/generator_MapIdentification.py index 70e160e0..7df77279 100644 --- a/generator/generator_MapIdentification.py +++ b/generator/generator_MapIdentification.py @@ -34,6 +34,9 @@ import Accas from .generator_python import PythonGenerator +from MapIdentification.mesScripts_MAPIDENTIFICATION import MAP_KEYS +from ConfigParser import RawConfigParser + def entryPoint(): """ Retourne les informations necessaires pour le chargeur de plugins @@ -47,7 +50,6 @@ def entryPoint(): 'factory' : MapIdentificationGenerator, } - class MapIdentificationGenerator(PythonGenerator): """ Ce generateur parcourt un objet de type JDC et produit @@ -59,42 +61,22 @@ class MapIdentificationGenerator(PythonGenerator): def gener(self,obj,format='brut',config=None,appli=None): self.initDico() self.text=PythonGenerator.gener(self,obj,format) - #if obj.isValid() :self.genereMap() - self.genereMap() return self.text - - def genereMap(self) : - ''' - Prepare le contenu du fichier de parametres python - ''' - print ('ds genereMap') - - def initDico(self) : if not hasattr(self,'schema') : self.schema="" self.dictParam={} self.dictValeur={} - + def writeDefault(self, fn): - #fileEXE = fn[:fn.rfind(".")] + '.py' - #f = open( str(fileEXE), 'wb') - #f.write( self.texteEXE ) - #f.close() - print ('ds writeDefault') - print (self.dictValeur) + """Convert comm file into MAP input file (INI)""" + config = RawConfigParser() + + config.add_section("c_solver_constitutive_law0d") + for key, value in self.dictValeur.iteritems(): + if key in KEYS: + config.set("c_solver_constitutive_law0d", key, value) - def generMCSIMP(self,obj) : - """ - Convertit un objet MCSIMP en texte python - Remplit le dictionnaire des MCSIMP - """ - - if obj.getGenealogie()[0][-6:-1]=="_PARA": - self.dictParam[obj.nom]=obj.valeur - else : - self.dictValeur[obj.nom]=obj.valeur - s=PythonGenerator.generMCSIMP(self,obj) - return s - - + input_filname = os.path.splitext(fn)[0] + ".input" + with open(input_filname,'w') as f_out : + config.write(f_out)