2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2007-2013 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..'))
24 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../InterfaceQT4'))
25 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../UiQT4'))
26 from Extensions.i18n import tr
27 from string import split,strip,lowercase,uppercase
30 import xml.etree.ElementTree as ET
31 from xml.dom import minidom
33 from PyQt4.QtGui import *
36 """Return a pretty-printed XML string for the Element.
38 rough_string = ET.tostring(elem, 'iso-8859-1')
39 reparsed = minidom.parseString(rough_string)
40 return reparsed.toprettyxml(indent=" ")
44 def __init__(self,cata,cataName):
45 self.fichier="/tmp/XML/"+cataName+".xml"
47 self.first=ET.Element('cata')
48 comment=ET.Comment("catalogue "+str(cataName))
49 self.first.append(comment)
50 self.reglesUtilisees=[]
51 self.validatorsUtilises=[]
52 self.constr_list_txt_cmd()
56 def ecrire_fichier(self):
59 f = codecs.open(self.fichier, "w", "ISO-8859-1")
60 #print prettify(self.first)
61 f.write(prettify(self.first))
64 print ("Impossible d'ecrire le fichier : "+ str(self.fichier))
66 def constr_list_txt_cmd(self):
67 mesCommandes=self.cata.JdC.commandes
68 self.commandes=ET.SubElement(self.first,'commandes')
69 for maCommande in mesCommandes:
70 maCommande.enregistreXMLStructure(self.commandes,self)
73 if __name__ == "__main__" :
74 #monCata="/local/noyret/Install_Eficas/MAP/mapcata.py"
75 #monCata="/local/noyret/Install_Eficas/Aster/Cata/cataSTA11/cata.py"
76 #monCata="/local/noyret/Install_Eficas/MAP/mapcata.py"
77 #monCata="/local/noyret/Install_Eficas/MAP/mapcata.py"
81 from Editeur import session
82 options=session.parse(sys.argv)
83 if options.code!= None : code=options.code
84 if options.cata!= None : monCata=options.cata
85 if options.ssCode!= None : ssCode=options.ssCode
87 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..',code))
89 from InterfaceQT4.ssIhm import QWParentSSIhm, appliEficasSSIhm
90 Eficas=appliEficasSSIhm(code=code)
91 parent=QWParentSSIhm(code,Eficas,version)
94 monreadercata = readercata.READERCATA( parent, parent )
95 Eficas.readercata=monreadercata
96 monCata=monreadercata.cata[0]
98 monCataXML=CatalogueXML(monCata,code)