From 8b93f7ce908c1769467afc2aaa5dec3747c81d53 Mon Sep 17 00:00:00 2001 From: Renaud Barate Date: Fri, 20 May 2011 10:01:00 +0000 Subject: [PATCH] Fix bug when opening OpenTURNS wrapper file --- Editeur/catadesc.py | 14 +++++--------- InterfaceQT4/editor.py | 2 +- InterfaceQT4/readercata.py | 21 ++++++++++++--------- Openturns_Study/catalogues_openturns.ini | 12 ++++++------ Openturns_Wrapper/catalogues_openturns.ini | 13 ++++++------- 5 files changed, 30 insertions(+), 32 deletions(-) diff --git a/Editeur/catadesc.py b/Editeur/catadesc.py index ad5d099a..bf54b9ee 100644 --- a/Editeur/catadesc.py +++ b/Editeur/catadesc.py @@ -75,13 +75,9 @@ class CatalogDescription: identifier = cata_tuple[1], cata_file_path = cata_tuple[2], file_format = cata_tuple[3]) - if len(cata_tuple) == 5 : - if cata_tuple[4] == "defaut": - desc.default = True - else: - desc = CatalogDescription(code = cata_tuple[0], - identifier = cata_tuple[1], - cata_file_path = cata_tuple[2], - file_format = cata_tuple[3], - file_format_in = cata_tuple[4]) + if len(cata_tuple) == 5: + if cata_tuple[4] == "defaut": + desc.default = True + else: + desc.file_format_in = cata_tuple[4] return desc diff --git a/InterfaceQT4/editor.py b/InterfaceQT4/editor.py index 77cb5fc9..407d95e0 100644 --- a/InterfaceQT4/editor.py +++ b/InterfaceQT4/editor.py @@ -135,7 +135,7 @@ class JDCEditor(QSplitter): self.jdc = self.readFile(self.fichier) else : self.jdc=jdc - if units is not None: + if self.jdc is not None and units is not None: self.jdc.recorded_units=units self.jdc.old_recorded_units=units else: diff --git a/InterfaceQT4/readercata.py b/InterfaceQT4/readercata.py index 57c82ba5..f5ad6ea9 100644 --- a/InterfaceQT4/readercata.py +++ b/InterfaceQT4/readercata.py @@ -84,20 +84,23 @@ class READERCATA: else: print "Catalog description cannot be interpreted: ", catalogue - # TODO: Remove this filter. Normally, CONFIGURATION should only define the catalogs for this code anyway. - # Non pas pour Map qui a une notion de sscode - for catalogue in all_cata_list: - #print catalogue.code - #print catalogue.file_format - if catalogue.code == self.code : - if (self.ssCode == None) or (self.ssCode == catalogue.file_format): - liste_cata_possibles.append(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. + if self.ssCode is None: + liste_cata_possibles = all_cata_list + else: + for catalogue in all_cata_list: + #print catalogue.code + #print catalogue.file_format + if catalogue.code == self.code and catalogue.file_format == self.ssCode: + liste_cata_possibles.append(catalogue) #print "___________" #print self.ssCode #print self.code if len(liste_cata_possibles)==0: - QMessageBox.critical( self.QWParent, "Import du catalogue","Pas de catalogue defini pour le code %s" % self.code) + QMessageBox.critical(self.QWParent, "Import du catalogue", + u"Pas de catalogue défini pour le code %s" % self.code) self.appliEficas.close() if self.appliEficas.salome == 0 : sys.exit(1) diff --git a/Openturns_Study/catalogues_openturns.ini b/Openturns_Study/catalogues_openturns.ini index 37e0255a..0cda9b69 100644 --- a/Openturns_Study/catalogues_openturns.ini +++ b/Openturns_Study/catalogues_openturns.ini @@ -1,10 +1,10 @@ -# Choix des catalogues import os -#rep_cata=os.path.dirname(os.path.abspath(__file__)) -rep_cata=os.getcwd() +from Editeur.catadesc import CatalogDescription + +# Choix des catalogues catalogues = ( -# (code,version,catalogue,formatIn,formatOut) - ('OPENTURNS_STUDY','V8',os.path.join(rep_cata,'OpenTURNS_Cata_Study_V8.py'),'openturns_study'), + CatalogDescription(identifier = "OPENTURNS_STUDY_V8", + cata_file_path = os.path.join(os.getcwd(), 'OpenTURNS_Cata_Study_V8.py'), + file_format = "openturns_study"), ) - diff --git a/Openturns_Wrapper/catalogues_openturns.ini b/Openturns_Wrapper/catalogues_openturns.ini index cbc9643b..ca462b70 100644 --- a/Openturns_Wrapper/catalogues_openturns.ini +++ b/Openturns_Wrapper/catalogues_openturns.ini @@ -1,11 +1,10 @@ -# Choix des catalogues import os -rep_cata=os.getcwd() +from Editeur.catadesc import CatalogDescription + +# Choix des catalogues catalogues = ( -# (code,version,catalogue,formatIn,formatOut) - #('OPENTURNS_WRAPPER','V1',os.path.join(rep_cata,'OpenTURNS_Cata_Wrapper_V1.py'),'openturns_wrapper','wrapper'), - ('OPENTURNS_WRAPPER','V3',os.path.join(rep_cata,'OpenTURNS_Cata_Wrapper_V4.py'),'openturns_wrapper','wrapper'), - #('OPENTURNS','Wrapper',os.path.join(rep_cata,'OpenTURNS_Cata_Wrapper_V1.py'),'openturns'), + CatalogDescription(identifier = "OPENTURNS_WRAPPER_V4", + cata_file_path = os.path.join(os.getcwd(), 'OpenTURNS_Cata_Wrapper_V4.py'), + file_format = "openturns_wrapper"), ) - -- 2.39.2