2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2007-2021 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
22 from __future__ import absolute_import
23 from __future__ import print_function
25 from builtins import str
26 from builtins import object
30 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..'))
31 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../InterfaceQT4'))
32 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../UiQT4'))
33 from Extensions.i18n import tr
34 from string import split,strip,lowercase,uppercase
37 import xml.etree.ElementTree as ET
38 from xml.dom import minidom
40 from PyQt4.QtGui import *
43 """Return a pretty-printed XML string for the Element.
45 rough_string = ET.tostring(elem, 'iso-8859-1')
46 reparsed = minidom.parseString(rough_string)
47 return reparsed.toprettyxml(indent=" ")
50 class CatalogueXML(object):
51 def __init__(self,cata,cataName):
52 self.fichier="/tmp/XML/"+cataName+".xml"
54 self.first=ET.Element('cata')
55 comment=ET.Comment("catalogue "+str(cataName))
56 self.first.append(comment)
57 self.reglesUtilisees=[]
58 self.validatorsUtilises=[]
59 self.constrListTxtCmd()
63 def ecrire_fichier(self):
66 f = codecs.open(self.fichier, "w", "ISO-8859-1")
67 #print prettify(self.first)
68 f.write(prettify(self.first))
71 print(("Impossible d'ecrire le fichier : "+ str(self.fichier)))
73 def constrListTxtCmd(self):
74 mesCommandes=self.cata.JdC.commandes
75 self.commandes=ET.SubElement(self.first,'commandes')
76 for maCommande in mesCommandes:
77 maCommande.enregistreXMLStructure(self.commandes,self)
80 if __name__ == "__main__" :
81 #monCata="/local/noyret/Install_Eficas/MAP/mapcata.py"
82 #monCata="/local/noyret/Install_Eficas/Aster/Cata/cataSTA11/cata.py"
83 #monCata="/local/noyret/Install_Eficas/MAP/mapcata.py"
84 #monCata="/local/noyret/Install_Eficas/MAP/mapcata.py"
88 from Editeur import session
89 options=session.parse(sys.argv)
90 if options.code!= None : code=options.code
91 if options.cata!= None : monCata=options.cata
92 if options.ssCode!= None : ssCode=options.ssCode
94 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..',code))
96 from InterfaceQT4.ssIhm import QWParentSSIhm, appliEficasSSIhm
97 Eficas=appliEficasSSIhm(code=code)
98 parent=QWParentSSIhm(code,Eficas,version)
101 monreadercata = readercata.READERCATA( parent, parent )
102 Eficas.readercata=monreadercata
103 monCata=monreadercata.cata
105 monCataXML=CatalogueXML(monCata,code)