Salome HOME
Maj Telemac2
[tools/eficas.git] / InterfaceQT4 / readercata.py
index a2ee29faa823ad1d2feb308e2884fa74c7d0da6e..fad67e8bdfcace37178bf672f3b70f7a54fa1219 100644 (file)
@@ -101,13 +101,37 @@ class ReaderCataCommun(object):
             if isinstance(catalogue, CatalogDescription): listeTousLesCatas.append(catalogue)
             elif isinstance(catalogue, tuple)           : listeTousLesCatas.append(CatalogDescription.createFromTuple(catalogue))
             else: print(("Catalog description cannot be interpreted: ", catalogue))
+    
+        if self.labelCode is  None: listeCataPossibles = listeTousLesCatas
+        else :
+            for catalogue in listeTousLesCatas:
+                if catalogue.code == self.code and catalogue.ssCode == self.ssCode:
+                    listeCataPossibles.append(catalogue)
+        
+        if len(listeCataPossibles)==0:
+            try :
+                QMessageBox.critical(self.QWParent, tr("Import du catalogue"),
+                                tr("Pas de catalogue defini pour le code ") + self.code)
+            except :
+                print("Pas de catalogue defini pour le code " + self.code)
+            if self.appliEficas.salome == 0 : sys.exit(1)
+            self.appliEficas.close()
+            return
 
-        # This filter is only useful for codes that have subcodes (like MAP).
-        # Otherwise, the "code" attribute of the catalog description can (should) be None.
-        if self.ssCode is None: listeCataPossibles = listeTousLesCatas
+        if self.labelCode is not None:
+            # La version a ete fixee
+            for cata in listeCataPossibles:
+                if self.labelCode == cata.identifier:
+                    self.fichierCata = cata.fichierCata
+                    self.labelCode   = cata.labelCode
+                    self.appliEficas.formatFichierOut = cata.formatFichierOut
+                    self.appliEficas.formatFichierIn  = cata.formatFichierIn
         else:
-            for catalogue in listeTousLesCatas:
-                if catalogue.code == self.code and catalogue.ssCode == self.ssCode: listeCataPossibles.append(catalogue)
+            cataChoiceList = []
+            for cata in listeCataPossibles:
+                if cata.selectable:
+                    if cata.default : cataChoiceList.insert(0, cata)
+                    else            : cataChoiceList.append(cata)
 
         # le catalogue est fixe dans la ligne de commande
         if self.appliEficas.fichierCata != None :