Salome HOME
optim eciture
[tools/eficas.git] / InterfaceQT4 / readercata.py
index b6e9957d3163a0557dc88fef13a38ba56d93a529..b3def9c2fc85f2ccc3c01d8698de248f0778a272 100644 (file)
     Il s'appuie sur la classe READERCATA
 """
 # Modules Python
+from __future__ import absolute_import
+from __future__ import print_function
+try :
+   from builtins import str
+   from builtins import object
+except : pass
+
 import time
 import os,sys,py_compile
 import traceback
-import cPickle
+import six.moves.cPickle
 import re
 import types
 
@@ -38,19 +45,15 @@ import analyse_catalogue
 import analyse_catalogue_initial
 import autre_analyse_cata
 import uiinfo
-from monChoixCata import MonChoixCata
+from .monChoixCata import MonChoixCata
 from Extensions.i18n import tr
 from Extensions.eficas_exception import EficasException
 
-from determine import monEnvQT5
-if monEnvQT5 :
-   from PyQt5.QtWidgets import QMessageBox, QApplication, QDialog
-else :
-   from PyQt4.QtGui  import *
+from PyQt5.QtWidgets import QMessageBox, QApplication, QDialog
 
 
 
-class READERCATA:
+class READERCATA(object):
 
    def __init__(self,QWParent, appliEficas):
       self.QWParent=QWParent
@@ -67,7 +70,7 @@ class READERCATA:
       self.cataitem=None
       self.cree_dico_inverse()
       if self.code=="TELEMAC": self.cree_dico_CasToCata()
-      #for k in self.dicoInverse.keys():
+      #for k in self.dicoInverse:
       #   genea= self.dicoInverse[k]
       #   for t in genea :
       #       print t[0]
@@ -87,10 +90,10 @@ class READERCATA:
       for catalogue in self.appliEficas.CONFIGURATION.catalogues:
           if isinstance(catalogue, CatalogDescription):
               all_cata_list.append(catalogue)
-          elif isinstance(catalogue, types.TupleType):
+          elif isinstance(catalogue, tuple):
               all_cata_list.append(CatalogDescription.create_from_tuple(catalogue))
           else:
-              print "Catalog description cannot be interpreted: ", catalogue
+              print(("Catalog description cannot be interpreted: ", catalogue))
 
       # This filter is only useful for codes that have subcodes (like MAP).
       # Otherwise, the "code" attribute of the catalog description can (should) be None.
@@ -143,7 +146,7 @@ class READERCATA:
 
       if self.fic_cata == None :
           if self.appliEficas.salome == 0 :
-             print "Pas de catalogue pour code %s, version %s" %(self.code,self.version_code)
+             print(("Pas de catalogue pour code %s, version %s" %(self.code,self.version_code)))
              sys.exit(1)
           else :
              self.appliEficas.close()
@@ -155,7 +158,7 @@ class READERCATA:
       self.cata = self.import_cata(self.fic_cata)
       if not self.cata :          
           QMessageBox.critical( self.QWParent, tr("Import du catalogue"),tr("Impossible d'importer le catalogue ")+ self.fic_cata)
-         self.appliEficas.close()
+          self.appliEficas.close()
           if self.appliEficas.salome == 0 :
              sys.exit(1)
       #
@@ -204,7 +207,7 @@ class READERCATA:
              a=self.appliEficas.CONFIGURATION.dRepMat[self.version_code]
           except :
              if self.code == "ASTER" :
-                print "Probleme avec le repertoire materiau"
+                print ("Probleme avec le repertoire materiau")
              a='.'
       self.appliEficas.CONFIGURATION.rep_mat=a
 
@@ -218,9 +221,9 @@ class READERCATA:
       self.appliEficas.listeAEnlever.append(rep_cata)
 
       
-      if sys.modules.has_key(nom_cata):
+      if nom_cata in list(sys.modules.keys()) :
         del sys.modules[nom_cata]
-      for k in sys.modules.keys():
+      for k in sys.modules:
         if k[0:len(nom_cata)+1] == nom_cata+'.':
           del sys.modules[k]
 
@@ -242,7 +245,7 @@ class READERCATA:
       try :
           o=__import__(nom_cata)
           return o
-      except Exception,e:
+      except Exception as e:
           traceback.print_exc()
           return 0
 
@@ -256,7 +259,6 @@ class READERCATA:
           contient le nom des mots cles dans le bon ordre
       """ 
       self.cata_ordonne_dico,self.appliEficas.liste_simp_reel=autre_analyse_cata.analyse_catalogue(self.cata)
-      #print self.cata_ordonne_dico,self.appliEficas.liste_simp_reel
 
    def Retrouve_Ordre_Cata_Standard(self):
       """ 
@@ -306,7 +308,7 @@ class READERCATA:
         self.fic_doc=getattr(self.appliEficas.CONFIGURATION,fic_doc )
         f=open(self.fic_doc)
       except:
-        print "Pas de fichier associe contenant des clefs documentaires"
+        print ("Pas de fichier associe contenant des clefs documentaires")
         return
 
       dict_clef_docu={}
@@ -316,7 +318,7 @@ class READERCATA:
           docu=l[deb:-1]
           dict_clef_docu[clef]=docu
       for oper in self.cata.JdC.commandes:
-           if dict_clef_docu.has_key(oper.nom):
+           if oper.nom in dict_clef_docu :
               oper.docu=dict_clef_docu[oper.nom]
 
    def cree_dico_inverse(self):
@@ -328,7 +330,7 @@ class READERCATA:
 
         #self.dicoFrancaisAnglais={}
         #self.dicoAnglaisFrancais={}
-        #for k in self.dicoInverse.keys():
+        #for k in self.dicoInverse:
         #    listefr=[]
         #    for nom, obj in self.dicoInverse[k] :
         #        listefr.append((tr(nom),obj))
@@ -340,20 +342,17 @@ class READERCATA:
    
    def cree_dico_CasToCata(self):
         if self.appliEficas.langue=="ang" :
-           from dicoCasEnToCata import DicoCasEnToCata as dicoCasToCata
+           from dicoCasEnToCata import dicoCasEnToCata as dicoCasToCata
         else :
-           from dicoCasFrToCata import DicoCasFrToCata as dicoCasToCata
+           from dicoCasFrToCata import dicoCasFrToCata as dicoCasToCata
         self.dicoCasToCata=dicoCasToCata
         
         
          
         
    def traite_entite(self,e):
-       #print "_______________"
-       #print e
-       #print e.nom
        boolIn=0
-       for (nomFils, fils) in e.entites.items() :
+       for (nomFils, fils) in list(e.entites.items()) :
           self.dicoMC[nomFils]=fils
           self.traite_entite(fils)
           boolIn=1
@@ -373,8 +372,8 @@ class READERCATA:
        #if niveau != 0 :
        #    if isinstance(e,A_BLOC.BLOC): print decale, e.condition 
        #    else :                           print decale, e. nom  
-       for (nom, fils) in e.entites.items() :
-           if  fils.entites.items() != [] : self.cree_rubrique(fils,dico,niveau+1)
+       for (nom, fils) in list(e.entites.items()) :
+           if  list(fils.entites.items()) != [] : self.cree_rubrique(fils,dico,niveau+1)
            #else : print (niveau+1)*"   ", nom