X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FTools%2FVerima%2FCreeDocuments%2FjobHtml.py;h=f0da68f1cc683798493392fbdeb09508222295f0;hb=a274ade365bd0f0e19d56c577acc4a13aa1972a7;hp=634827bf7a7d799e1d3d0cd56d08e5183d176e46;hpb=e8173b4ff130ddb26d165c92403ef847fdfb8be2;p=modules%2Fsmesh.git diff --git a/src/Tools/Verima/CreeDocuments/jobHtml.py b/src/Tools/Verima/CreeDocuments/jobHtml.py index 634827bf7..f0da68f1c 100755 --- a/src/Tools/Verima/CreeDocuments/jobHtml.py +++ b/src/Tools/Verima/CreeDocuments/jobHtml.py @@ -1,19 +1,36 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- +#!/usr/bin/env python3 +# Copyright (C) 2013-2021 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, or (at your option) any later version. +# +# 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 string import os -dir=os.path.dirname(os.path.abspath(__file__)) -FichierEntete=os.path.join(dir,'templatesHtml/entete.html') -FichierMaillageEntete=os.path.join(dir,'templatesHtml/maillageEntete.html') -FichierJob=os.path.join(dir,'templatesHtml/job.html') -FichierTableau=os.path.join(dir,'templatesHtml/tableau.html') -FichierLigne=os.path.join(dir,'templatesHtml/ligne.html') -FichierFinTableau=os.path.join(dir,'templatesHtml/tableauFin.html') -FichierSansGroupe=os.path.join(dir,'templatesHtml/sansGroupe.html') -FichierGroupeRatio=os.path.join(dir,'templatesHtml/groupeRatio.html') -FichierGroupeTaille=os.path.join(dir,'templatesHtml/groupeTaille.html') +adir=os.path.dirname(os.path.abspath(__file__)) +FichierEntete=os.path.join(adir,'templatesHtml/entete.html') +FichierMaillageEntete=os.path.join(adir,'templatesHtml/maillageEntete.html') +FichierJob=os.path.join(adir,'templatesHtml/job.html') +FichierTableau=os.path.join(adir,'templatesHtml/tableau.html') +FichierLigne=os.path.join(adir,'templatesHtml/ligne.html') +FichierFinTableau=os.path.join(adir,'templatesHtml/tableauFin.html') +FichierSansGroupe=os.path.join(adir,'templatesHtml/sansGroupe.html') +FichierGroupeRatio=os.path.join(adir,'templatesHtml/groupeRatio.html') +FichierGroupeTaille=os.path.join(adir,'templatesHtml/groupeTaille.html') def compte_all(texte, subString): @@ -26,7 +43,7 @@ def compte_all(texte, subString): start = trouve + len(subString) def FormateTexte(texte,dico): - for clef in list(dico.keys()): + for clef in dico: texteARemplacer="%"+str(clef)+"%" remplacement=dico[clef] if texte.find(texteARemplacer) < 0 : @@ -47,33 +64,33 @@ def FormateLigne(texte,nb): return texte def CreeEntete(dico): - texteIni=open(FichierEntete).read() + texteIni=open(FichierEntete, 'r', encoding='utf8').read() texteRetour=FormateTexte(texteIni,dico) return texteRetour def CreeMaillage(dico): - texteIni=open(FichierMaillageEntete).read() + texteIni=open(FichierMaillageEntete, 'r', encoding='utf8').read() texteRetour=FormateTexte(texteIni,dico) return texteRetour def CreeJob(dico): - texte=open(FichierJob).read() + texte=open(FichierJob, 'r', encoding='utf8').read() texteRetour=FormateTexte(texte,dico) return texteRetour def CreeGroupeTaille(dico): - texte=open(FichierGroupeTaille).read() + texte=open(FichierGroupeTaille, 'r', encoding='utf8').read() texteRetour=FormateTexte(texte,dico) return texteRetour def CreeGroupeRatio(dico): - texte=open(FichierGroupeRatio).read() + texte=open(FichierGroupeRatio, 'r', encoding='utf8').read() texteRetour=FormateTexte(texte,dico) return texteRetour def CreeMailleOuGroupe(dico,nb): - texteIni=open(FichierTableau).read() + texteIni=open(FichierTableau, 'r', encoding='utf8').read() texteLigneIni=open(FichierLigne).read() for i in range (2,nb+1) : texteLigne=FormateLigne(texteLigneIni,i) @@ -81,16 +98,15 @@ def CreeMailleOuGroupe(dico,nb): texteRetour=FormateTexte(texteIni,dico) - finTexte=open(FichierFinTableau).read() + finTexte=open(FichierFinTableau, 'r', encoding='utf8').read() texteFinal=texteRetour+finTexte return texteFinal def EcritFichier(texte,filename): - fp=open(filename,'w') - fp.write(texte) - fp.close() + with open(filename,'w',encoding='utf8') as fp: + fp.write(texte) class Document: