From: Paul RASCLE Date: Wed, 22 May 2019 12:45:32 +0000 (+0200) Subject: porting to SALOME 9.3: 2to3 X-Git-Tag: SH_V2_2_0~27^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bebd0772fe170a8f71c282e82eb5bc2e079546eb;p=modules%2Fhydrosolver.git porting to SALOME 9.3: 2to3 --- diff --git a/src/HYDROGUI/BndConditionsDialog.py b/src/HYDROGUI/BndConditionsDialog.py index b278364..e86b16c 100755 --- a/src/HYDROGUI/BndConditionsDialog.py +++ b/src/HYDROGUI/BndConditionsDialog.py @@ -39,7 +39,7 @@ def get_med_groups_on_edges(file_path): med_file_mesh = MEDFileMesh.New(file_path) groups = list(med_file_mesh.getGroupsOnSpecifiedLev(-1)) except Exception as e: - print e.what() + print(e.what()) return [] return groups @@ -48,7 +48,7 @@ def get_med_groups_on_edges(file_path): def get_preset_name(presets, lihbor, liubor, livbor, litbor): name = 'Custom' res = (lihbor, liubor, livbor, litbor) - for key, val in presets.iteritems(): + for key, val in presets.items(): if val == res: name = key break @@ -180,18 +180,18 @@ class BoundaryConditionsDialog(QDialog): def on_apply(self): # Save boundary conditions file if not self.is_valid(): - print 'Not valid' + print('Not valid') return False if self.sameAsInputCB.isChecked(): file_path = self.bndConditionsFileEdit.text() else: file_path = self.resultBndConditionsFileEdit.text() - print 'File path:', file_path + print('File path:', file_path) writer = boundaryConditions.BoundaryConditionWriter(file_path) conditions = [] - for row_nb in xrange(0, self.boundaryConditionsTable.rowCount()): + for row_nb in range(0, self.boundaryConditionsTable.rowCount()): lihbor = str(self.boundaryConditionsTable.item(row_nb, 1).text()) liubor = str(self.boundaryConditionsTable.item(row_nb, 2).text()) livbor = str(self.boundaryConditionsTable.item(row_nb, 3).text()) @@ -260,7 +260,7 @@ class BoundaryConditionsDialog(QDialog): preset = str(combo.currentText()) - if preset and self.presets.has_key(preset): + if preset and preset in self.presets: values = self.presets[preset] row_nb = combo.property(ROW_PROPERTY_NAME) @@ -308,7 +308,7 @@ class BoundaryConditionsDialog(QDialog): combo = QComboBox(self) #combo.addItem('') if len(self.presets) > 0: - items = self.presets.keys() + items = list(self.presets.keys()) items.sort() combo.addItems(items) @@ -345,9 +345,9 @@ class BoundaryConditionsDialog(QDialog): is_updated = False nb_rows = self.boundaryConditionsTable.rowCount() - for row_nb in xrange(0, nb_rows): + for row_nb in range(0, nb_rows): group_name = str(self.boundaryConditionsTable.item(row_nb, 5).text()) - if self.input_conditions.has_key(group_name): + if group_name in self.input_conditions: values = self.input_conditions[group_name] #print values @@ -393,7 +393,7 @@ class BoundaryConditionsDialog(QDialog): elif len(self.get_output_path())==0: QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Output file path is empty.")) else: - for row_nb in xrange(0, self.boundaryConditionsTable.rowCount()): + for row_nb in range(0, self.boundaryConditionsTable.rowCount()): has_empty_cells = True lihbor = str(self.boundaryConditionsTable.item(row_nb, 1).text()) liubor = str(self.boundaryConditionsTable.item(row_nb, 2).text()) diff --git a/src/HYDROGUI/HYDROSOLVERGUI.py b/src/HYDROGUI/HYDROSOLVERGUI.py index 4c4812c..1e62aff 100755 --- a/src/HYDROGUI/HYDROSOLVERGUI.py +++ b/src/HYDROGUI/HYDROSOLVERGUI.py @@ -277,7 +277,7 @@ def _getContext(): ### def _setContext(studyID): global __study2context__, __current_context__ - if not __study2context__.has_key(studyID): + if studyID not in __study2context__: __study2context__[studyID] = GUIcontext() pass __current_context__ = __study2context__[studyID] @@ -336,10 +336,10 @@ def createPopupMenu(popup, context): def OnGUIEvent(commandID): try: dict_command[commandID]() - except HSGUIException, exc: + except HSGUIException as exc: QMessageBox.critical(sgPyQt.getDesktop(), QApplication.translate("OnGUIEvent", "Error"), - unicode(exc)) + str(exc)) except: logger.exception("Unhandled exception caught in HYDROSOLVER GUI") msg = QApplication.translate("OnGUIEvent", @@ -377,9 +377,9 @@ def generate_param_study_python(): ed = hydro_study.HydroStudyEditor() sobj = get_and_check_selected_file_path() ed.generate_study_script(sobj) - except SALOME.SALOME_Exception, exc: + except SALOME.SALOME_Exception as exc: salome.sg.updateObjBrowser(0) - msg = unicode(QApplication.translate("generate_telemac2d_python", + msg = str(QApplication.translate("generate_telemac2d_python", "An error happened while trying to generate telemac2d Python script:")) msg += "\n" + exc.details.text raise HSGUIException(msg) @@ -393,9 +393,9 @@ def generate_param_study_yacs(): ed = hydro_study.HydroStudyEditor() sobj = get_and_check_selected_file_path() ed.generate_study_yacs(sobj) - except SALOME.SALOME_Exception, exc: + except SALOME.SALOME_Exception as exc: salome.sg.updateObjBrowser(0) - msg = unicode(QApplication.translate("generate_telemac2d_yacs", + msg = str(QApplication.translate("generate_telemac2d_yacs", "An error happened while trying to generate telemac2d Python script:")) msg += "\n" + exc.details.text raise HSGUIException(msg) diff --git a/src/HYDROTools/boundaryConditions.py b/src/HYDROTools/boundaryConditions.py index c090777..647c298 100644 --- a/src/HYDROTools/boundaryConditions.py +++ b/src/HYDROTools/boundaryConditions.py @@ -39,7 +39,7 @@ class PresetReader(): self._errors.append("Line #%s: wrong number of values in the preset." % line_number) elif values[0].strip() == "": self._errors.append("Line #%s: empty name of the preset." % line_number) - elif presets.has_key(values[0]): + elif values[0] in presets: self._errors.append("Line #%s: preset name %s is already used." % (line_number, values[0])) else: name = values[0] diff --git a/src/HYDROTools/interpolS.py b/src/HYDROTools/interpolS.py index 8401a96..a2740eb 100644 --- a/src/HYDROTools/interpolS.py +++ b/src/HYDROTools/interpolS.py @@ -83,7 +83,7 @@ def assignStrickler(case_name, med_file_name, output_file_name, med_field_name=' medenum.MED_NODE, medenum.MED_NONE, medenum.MED_FULL_INTERLACE, medenum.MED_ALL_CONSTITUENT, len(values), values) - print "MED field '%s' on %s nodes has been created." % (med_field_name, nb_nodes) + print("MED field '%s' on %s nodes has been created." % (med_field_name, nb_nodes)) # close MED file medfile.MEDfileClose(fid) \ No newline at end of file diff --git a/src/salome_hydro/assignStrickler_gui.py b/src/salome_hydro/assignStrickler_gui.py index 9eb791d..5d01d1d 100644 --- a/src/salome_hydro/assignStrickler_gui.py +++ b/src/salome_hydro/assignStrickler_gui.py @@ -11,7 +11,7 @@ salome.salome_init() import HYDROPy from salome.hydrotools.interpolS import assignStrickler -from generate_interpolz import replace +from .generate_interpolz import replace from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox from PyQt5 import uic diff --git a/src/salome_hydro/boundary_conditions/eficas/boundary_conditions_cata.py b/src/salome_hydro/boundary_conditions/eficas/boundary_conditions_cata.py index 46f73dc..4e0befe 100644 --- a/src/salome_hydro/boundary_conditions/eficas/boundary_conditions_cata.py +++ b/src/salome_hydro/boundary_conditions/eficas/boundary_conditions_cata.py @@ -25,7 +25,7 @@ class grma(GEOM): Method __convert__ is redefined to skip the test on the string length. """ def __convert__(cls, valeur): - if isinstance(valeur, (str, unicode)): + if isinstance(valeur, str): return valeur.strip() raise ValueError(_('A string is expected')) @@ -37,24 +37,24 @@ JdC = JDC_CATA(regles = (AU_MOINS_UN('BOUNDARY_CONDITION',)), BOUNDARY_CONDITION = PROC( nom = "BOUNDARY_CONDITION", op = None, - fr = u"Définition d'une condition limite pour Telemac2D", - ang = u"Definition of a boundary condition for Telemac2D", + fr = "Définition d'une condition limite pour Telemac2D", + ang = "Definition of a boundary condition for Telemac2D", GROUP = SIMP(statut = "o", typ = grma, - fr = u"Groupe sur lequel la condition limite est définie", - ang = u"Group on which the boundary condition is defined", + fr = "Groupe sur lequel la condition limite est définie", + ang = "Group on which the boundary condition is defined", ), LIHBOR = SIMP(statut = "o", typ = "I", - fr = u"Type de condition limite pour la hauteur d'eau", - ang = u"Boundary condition type for the water height", + fr = "Type de condition limite pour la hauteur d'eau", + ang = "Boundary condition type for the water height", ), LIUBOR = SIMP(statut = "o", typ = "I", - fr = u"Type de condition limite pour la composante U de la vitesse", - ang = u"Boundary condition type for the U component of the water velocity", + fr = "Type de condition limite pour la composante U de la vitesse", + ang = "Boundary condition type for the U component of the water velocity", ), LIVBOR = SIMP(statut = "o", typ = "I", - fr = u"Type de condition limite pour la composante V de la vitesse", - ang = u"Boundary condition type for the V component of the water velocity", + fr = "Type de condition limite pour la composante V de la vitesse", + ang = "Boundary condition type for the V component of the water velocity", ), ) TEXTE_NEW_JDC="BOUNDARY_CONDITION()" diff --git a/src/salome_hydro/generate_interpolz.py b/src/salome_hydro/generate_interpolz.py index 93b22dd..cb2f9be 100644 --- a/src/salome_hydro/generate_interpolz.py +++ b/src/salome_hydro/generate_interpolz.py @@ -15,7 +15,7 @@ def replace( lines, pattern, subst ): del lines[i] name = pattern[1:-1] lines.insert( i, "%s = {}\n" % name ) - keys = subst.keys() + keys = list(subst.keys()) keys.sort() i = i+1 for k in keys: diff --git a/src/salome_hydro/interpolz_gui.py b/src/salome_hydro/interpolz_gui.py index 16e06c5..87907c8 100644 --- a/src/salome_hydro/interpolz_gui.py +++ b/src/salome_hydro/interpolz_gui.py @@ -23,7 +23,7 @@ import SalomePyQt import libSALOME_Swig salome_gui = libSALOME_Swig.SALOMEGUI_Swig() -from generate_interpolz import generate, generate_B +from .generate_interpolz import generate, generate_B def get_med_groups( file_path ): #print "get_med_groups", file_path @@ -31,24 +31,24 @@ def get_med_groups( file_path ): #meshes = MEDLoader.GetMeshNames(file_path) (meshes, status) = smesh.CreateMeshesFromMED(file_path) except: - print 'No meshes found' + print('No meshes found') return [] if len(meshes)==0: - print 'No mesh found' + print('No mesh found') return [] mesh1 = meshes[0] - print 'Found mesh:', mesh1 + print('Found mesh:', mesh1) try: #groups = list(MEDLoader.GetMeshGroupsNames(file_path, mesh1)) grps = mesh1.GetGroups() groups = [grp.GetName() for grp in grps if grp.GetType() == SMESH.FACE] if len(groups) == 0: - print "Problem! There are no groups of faces in the mesh!" - print "Please create at least the groups of faces corresponding to each region of the HYDRO case" + print("Problem! There are no groups of faces in the mesh!") + print("Please create at least the groups of faces corresponding to each region of the HYDRO case") return [] - print 'Found groups:', groups + print('Found groups:', groups) except: - print 'No groups found' + print('No groups found') return [] return groups @@ -159,7 +159,7 @@ class InterpolzDlg( QDialog ): def onMEDChanged( self ): self.med_groups = get_med_groups( str(self.MEDFile.text()) ) - print self.med_groups + print(self.med_groups) n = len( self.med_groups ) self.Groups.setRowCount( n ) self.medGroupNames.clear() @@ -208,7 +208,7 @@ class InterpolzDlg( QDialog ): def onApply( self ): path = str(self.OutputPath.text()) med_file = str(self.MEDFile.text()) - print 'current TAB = ', self.tabWidget.currentIndex() + print('current TAB = ', self.tabWidget.currentIndex()) if self.tabWidget.currentIndex() == 0: #calc case tab calc_case = str(self.CalcCase.text()) med_groups_regions = {} diff --git a/src/salome_hydro/param_study/eficas/appli.py b/src/salome_hydro/param_study/eficas/appli.py index a4411d4..9a5d017 100644 --- a/src/salome_hydro/param_study/eficas/appli.py +++ b/src/salome_hydro/param_study/eficas/appli.py @@ -82,7 +82,7 @@ class EficasForParamStudyAppli(eficasSalome.MyEficas): """ try: self.ed.find_or_create_param_study(jdcPath) - except Exception, exc: + except Exception as exc: msgError = "Can't add file to Salome study tree" logger.exception(msgError) QMessageBox.warning(self, self.tr("Warning"), diff --git a/src/salome_hydro/param_study/eficas/param_study_cata.py b/src/salome_hydro/param_study/eficas/param_study_cata.py index c95ea1c..ab9e09c 100644 --- a/src/salome_hydro/param_study/eficas/param_study_cata.py +++ b/src/salome_hydro/param_study/eficas/param_study_cata.py @@ -47,7 +47,7 @@ class Tuple: self.ntuple=ntuple def __convert__(self,valeur): - if type(valeur) == types.StringType: + if type(valeur) == bytes: return None if len(valeur) != self.ntuple: return None @@ -66,75 +66,75 @@ JdC = JDC_CATA(regles = (UN_PARMI('TELEMAC2D',)), TELEMAC2D = PROC( nom = "TELEMAC2D", op = None, - fr = u"Définition d'un cas d'étude Telemac2D", - ang = u"Definition of a Telemac2D study case", + fr = "Définition d'un cas d'étude Telemac2D", + ang = "Definition of a Telemac2D study case", STEERING_FILE = SIMP(statut = "o", typ = 'Fichier', - fr = u"Fichier de description du cas", - ang = u"Case description file", + fr = "Fichier de description du cas", + ang = "Case description file", ), USER_FORTRAN = SIMP(statut = "f", typ = 'FichierOuRepertoire', fr = "Fichier Fortran utilisateur", - ang = u"Fortran user file", + ang = "Fortran user file", ), WORKING_DIRECTORY = SIMP(statut = "o", typ = 'Repertoire', defaut = '/tmp', fr = "Repertoire de travail", - ang = u"Working directory user file", + ang = "Working directory user file", ), RESULT_DIRECTORY = SIMP(statut = "f", typ = 'Repertoire', fr = "Repertoire de travail", - ang = u"Working directory user file", + ang = "Working directory user file", ), RESULTS_FILE_NAME = SIMP(statut = "f", typ = 'TXM', - fr = u"Fichier des resultats (Ecrasera celui dans le fichier cas)", - ang = u"Results file (Will replace the one in the steering file)" + fr = "Fichier des resultats (Ecrasera celui dans le fichier cas)", + ang = "Results file (Will replace the one in the steering file)" ), Consigne = SIMP(statut ="o", homo="information", typ="TXM", defaut = "All index are in Python numbering (Starting from 0)", ), INPUT_VARIABLE = FACT(statut = 'f', max = '**', - fr = u"Variable d'entrée du calcul", - ang = u"Computation input variable", + fr = "Variable d'entrée du calcul", + ang = "Computation input variable", NAME = SIMP(statut = "o", typ = 'TXM', - fr = u"Nom de la variable (format Python)", - ang = u"Variable name (Python format)" + fr = "Nom de la variable (format Python)", + ang = "Variable name (Python format)" ), VAR_INFO = FACT(statut = "o", - fr = u'Variable du modèle Telemac2D', - ang = u'Telemac2D model variable', + fr = 'Variable du modèle Telemac2D', + ang = 'Telemac2D model variable', VAR_NAME = SIMP(statut = "o", typ = 'TXM', intoSug = get_list_var_api('TELEMAC2D'), - fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")', - ang = u'Model variable name (ex: "MODEL.DEBIT")' + fr = 'Nom de la variable du modèle (ex: "MODEL.DEBIT")', + ang = 'Model variable name (ex: "MODEL.DEBIT")' ), DEFAULT_VALUE = SIMP(statut = "o", typ = 'TXM', - fr = u'Valeur par défaut', - ang = u'Default value', + fr = 'Valeur par défaut', + ang = 'Default value', ), ZONE_DEF = FACT(statut = "o", - ang = u'Variable definition area', - fr = u'Zone de définition de la variable', + ang = 'Variable definition area', + fr = 'Zone de définition de la variable', TYPE = SIMP(statut = "o", typ = 'TXM', into = ['INDEX', 'RANGE', 'POLYGON', 'POLYGON_FILE'], fenetreIhm="menuDeroulant", - fr = u'Type de definition de la variable', - ang = u'Type of definition for the variable', + fr = 'Type de definition de la variable', + ang = 'Type of definition for the variable', ), b_INDEX = BLOC(condition = "TYPE == 'INDEX'", INDEX = SIMP(statut = "o", typ = Tuple(3), defaut = (0, 0, 0), ang = "Index of the variable", - fr = u"Indice de la variable", + fr = "Indice de la variable", validators = VerifTypeTuple(('I', 'I', 'I')), ), ), b_RANGE = BLOC(condition = "TYPE == 'RANGE'", RANGE = SIMP(statut = "o", typ = 'TXM', - fr = u"Liste d'index pour des tableaux à une dimension ex: [1,3:8,666]", + fr = "Liste d'index pour des tableaux à une dimension ex: [1,3:8,666]", ang = "Range of index for one dimension arrays ex: [1,3:8,666]", ), Consigne = SIMP(statut ="o", homo="information", typ="TXM", @@ -145,8 +145,8 @@ TELEMAC2D = PROC( POLYGON = SIMP(statut = "o", typ = Tuple(2), max = '**', - fr = u"Liste des sommets (coordonnées X,Y) du " - u"polygone définissant le contour de la zone", + fr = "Liste des sommets (coordonnées X,Y) du " + "polygone définissant le contour de la zone", ang = "List of points (X,Y coordinates) of the " "polygon defining the border of the area", validators = VerifTypeTuple(('R', 'R')), @@ -154,15 +154,15 @@ TELEMAC2D = PROC( ), b_POLYGON_FILE = BLOC(condition = "TYPE == 'POLYGON_FILE'", POLYGON_FILE = FACT(statut = "o", - fr = u"Polygon dans un fichier", + fr = "Polygon dans un fichier", ang = "Polygone in a file", FILE_NAME = SIMP(statut = "o", typ = 'Fichier', - fr = u"Fichier contenant les info du polygone", + fr = "Fichier contenant les info du polygone", ang = "File containing the polygon info", ), SEPARATOR = SIMP(statut = "o", typ = 'TXM', defaut = ',', - fr = u"Separateur pour le fichier de polygone", + fr = "Separateur pour le fichier de polygone", ang = "Separator for the polygon file", ), ), @@ -171,27 +171,27 @@ TELEMAC2D = PROC( ), ), OUTPUT_VARIABLE = FACT(statut = 'f', max = '**', - fr = u"Variable de sortie du calcul", - ang = u"Computation output variable", + fr = "Variable de sortie du calcul", + ang = "Computation output variable", NAME = SIMP(statut = "o", typ = 'TXM', - fr = u"Nom de la variable", - ang = u"Variable name", + fr = "Nom de la variable", + ang = "Variable name", ), VAR_INFO = FACT(statut = "o", - fr = u'Variable du modèle Telemac2D', - ang = u'Telemac2D model variable', + fr = 'Variable du modèle Telemac2D', + ang = 'Telemac2D model variable', VAR_NAME = SIMP(statut = "o", typ = 'TXM', intoSug = get_list_var_api('TELEMAC2D'), - fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")', - ang = u'Model variable name (ex: "MODEL.DEBIT")', + fr = 'Nom de la variable du modèle (ex: "MODEL.DEBIT")', + ang = 'Model variable name (ex: "MODEL.DEBIT")', ), ZONE_DEF = FACT(statut = "o", - ang = u'Variable definition area', - fr = u'Zone de définition de la variable', + ang = 'Variable definition area', + fr = 'Zone de définition de la variable', INDEX = SIMP(statut = "o", typ = Tuple(3), defaut = (0, 0, 0, ), ang = "Index of the point / border", - fr = u"Indice du point ou de la frontière", + fr = "Indice du point ou de la frontière", validators = VerifTypeTuple(('I', 'I', 'I')), ), ), diff --git a/src/salome_hydro/run_study/eficas/appli.py b/src/salome_hydro/run_study/eficas/appli.py index 874cc99..2446044 100755 --- a/src/salome_hydro/run_study/eficas/appli.py +++ b/src/salome_hydro/run_study/eficas/appli.py @@ -65,7 +65,7 @@ class EficasForRunStudyAppli(eficasSalome.MyEficas): """ try: self.ed.find_or_create_run_study(jdcPath) - except Exception, exc: + except Exception as exc: msgError = "Can't add file to Salome study tree" logger.exception(msgError) QMessageBox.warning(self, self.tr("Warning"), diff --git a/src/salome_hydro/run_study/eficas/run_study_cata.py b/src/salome_hydro/run_study/eficas/run_study_cata.py index 8c1e9f8..64d5f3e 100644 --- a/src/salome_hydro/run_study/eficas/run_study_cata.py +++ b/src/salome_hydro/run_study/eficas/run_study_cata.py @@ -25,17 +25,17 @@ JdC = JDC_CATA(regles = (UN_PARMI('RUN_STUDY',)), ) RUN_STUDY = PROC( nom = "RUN_STUDY", op = None, - fr = u"Définition d'un cas pour le lanceur Python", - ang = u"Definition of a case for the Python launcher", + fr = "Définition d'un cas pour le lanceur Python", + ang = "Definition of a case for the Python launcher", CODE = SIMP(statut = "o", typ = "TXM", into = codelist, defaut = "telemac2d", - fr = u"Code à exécuter", - ang = u"Code to run"), + fr = "Code à exécuter", + ang = "Code to run"), FICHIER_CAS = SIMP(statut = "o", typ = 'Fichier', - fr = u"Fichier de description du cas", - ang = u"Case description file"), + fr = "Fichier de description du cas", + ang = "Case description file"), REPERTOIRE_TRAVAIL = SIMP(statut = "f", typ = 'Repertoire', - fr = u"Répertoire de travail", - ang = u"Working directory"), + fr = "Répertoire de travail", + ang = "Working directory"), ) TEXTE_NEW_JDC="RUN_STUDY()" diff --git a/src/salome_hydro/run_study/gui.py b/src/salome_hydro/run_study/gui.py index 0a3e9f2..94be873 100755 --- a/src/salome_hydro/run_study/gui.py +++ b/src/salome_hydro/run_study/gui.py @@ -22,8 +22,8 @@ from salome.hydro.gui_utils import get_and_check_selected_file_path from salome.hydro.study import jdc_to_dict from salome.hydro.run_study.eficas.appli import EficasForRunStudyAppli -from launcher import run_study -from genjobwindow import GenJobDialog +from .launcher import run_study +from .genjobwindow import GenJobDialog from PyQt5.QtWidgets import QFileDialog diff --git a/src/salome_hydro/run_study/launcher.py b/src/salome_hydro/run_study/launcher.py index 3702551..b1ee58c 100644 --- a/src/salome_hydro/run_study/launcher.py +++ b/src/salome_hydro/run_study/launcher.py @@ -63,7 +63,7 @@ def run_study(param_dict): # Launch the command logger.debug("Running the following command in xterm: %s" % cmd) args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "-hold", "-l", "-e", cmd] - if param_dict.has_key('batchExec'): + if 'batchExec' in param_dict: if param_dict['batchExec'] == True: args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "+hold", "-l", "-e", cmd] subprocess.Popen(args, cwd = wrkdir) diff --git a/src/salome_hydro/study.py b/src/salome_hydro/study.py index f4983b7..dd066ee 100644 --- a/src/salome_hydro/study.py +++ b/src/salome_hydro/study.py @@ -52,16 +52,16 @@ def jdc_to_dict(jdc, command_list): context = {} for command in command_list: context[command] = _args_to_dict - exec "parameters = " + jdc.strip() in context + exec("parameters = " + jdc.strip(), context) return context['parameters'] def _args_to_dict(**kwargs): return kwargs def get_jdc_dict_var_as_tuple(jdc_dict, varname): - if not jdc_dict.has_key(varname): + if varname not in jdc_dict: return tuple() - elif not isinstance(jdc_dict[varname], types.TupleType): + elif not isinstance(jdc_dict[varname], tuple): return (jdc_dict[varname],) else: return jdc_dict[varname] diff --git a/src/salome_hydro/telma/eficas/appli.py b/src/salome_hydro/telma/eficas/appli.py index b4a9461..ca24c63 100755 --- a/src/salome_hydro/telma/eficas/appli.py +++ b/src/salome_hydro/telma/eficas/appli.py @@ -81,7 +81,7 @@ class EficasForTelmaAppli(eficasSalome.MyEficas): """ try: self.ed.find_or_create_telma(jdcPath) - except Exception, exc: + except Exception as exc: msgError = "Can't add file to Salome study tree" logger.exception(msgError) QMessageBox.warning(self, self.tr("Warning"), diff --git a/src/salome_hydro/test_interpolz_gui.py b/src/salome_hydro/test_interpolz_gui.py index f92d53e..19880eb 100644 --- a/src/salome_hydro/test_interpolz_gui.py +++ b/src/salome_hydro/test_interpolz_gui.py @@ -1,5 +1,5 @@ -from interpolz_gui import InterpolzDlg +from .interpolz_gui import InterpolzDlg dlg = InterpolzDlg() dlg.show() diff --git a/tests/boundaryConditionsTest.py b/tests/boundaryConditionsTest.py index bcdba07..238413f 100644 --- a/tests/boundaryConditionsTest.py +++ b/tests/boundaryConditionsTest.py @@ -20,13 +20,13 @@ class TestBoundaryConditions(unittest.TestCase): presets = reader.read() self.assertEqual(3, len(presets)) - self.assertEqual(True, presets.has_key("Closed boundaries/walls")) + self.assertEqual(True, "Closed boundaries/walls" in presets) self.assertEqual((2,2,2,2), presets["Closed boundaries/walls"]) - self.assertEqual(True, presets.has_key("Incident waves")) + self.assertEqual(True, "Incident waves" in presets) self.assertEqual((1,1,1,None), presets["Incident waves"]) - self.assertEqual(True, presets.has_key("Free T")) + self.assertEqual(True, "Free T" in presets) self.assertEqual((None,None,None,4), presets["Free T"]) def testRead(self):