Salome HOME
commentaire
[tools/eficas.git] / Traducteur / load.py
index fc95db7e45ef4949f24e4208b21fc1ef3fabd3ef..f6815a2e93bb84059be9323d7036062310a2e9a4 100644 (file)
@@ -1,20 +1,43 @@
 # -*- coding: utf-8 -*-
+# Copyright (C) 2007-2013   EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
 
 import os
 import re
-import parseur
-from mocles import parseKeywords
+from Traducteur import parseur
+from Traducteur.mocles import parseKeywords
 
+import sets
+jdcSet=sets.Set()
 
 
-class JDC:
+class JDCTrad:
     """Cet objet conserve toutes les informations relatives à un fichier de commandes .comm"""
 
-    def __init__(self,filename,src,atraiter):
+    def __init__(self,src,atraiter):
     #----------------------------------------
-        self.filename = os.path.abspath(filename)
         self.atraiter=atraiter
         self.init(src,atraiter)
+        commands= self.root.childNodes[:]
+        commands.reverse()
+        for c in commands:
+            jdcSet.add(c.name)
 
     def init(self,src,atraiter):
     #---------------------------
@@ -109,11 +132,16 @@ class JDC:
         self.lines[numeroLigne]=nouveauTexte
 
 def getJDC(filename,atraiter):
-#---------------------------_
+#----------------------------
 # lit le JDC
     f=open(filename)
     src=f.read()
     f.close()
-    jdc=JDC(filename,src,atraiter)
+    jdc=JDCTrad(src,atraiter)
     return jdc
 
+def getJDCFromTexte(texte,atraiter):
+#-----------------------------------
+# lit le JDC
+    jdc=JDCTrad(texte,atraiter)
+    return jdc