1 # Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #SHAPER_SRC = os.environ['SHAPER_SRC']
23 SHAPER_SRC = os.environ['PWD']
24 # VERBOSE_FLAG = os.environ['VERBOSE_FLAG']
27 OPERATORS=[">", "<", "+", "=", "-", "*", "/"]
29 def create_warning_generator(fichier):
31 fichier est le fichier de log cpplint ouvert à la position courante.
32 Un trou dans le fichier résulte en l'arrêt de la génération
35 ligne = fichier.readline()
37 while ligne.strip("\n") :
38 ligne = ligne.decode(ENCODING)
39 liste = ligne.split(":")
40 print("Size of liste = ", len(liste))
41 print("ligne = ", ligne)
42 print("n° ligne = ", i)
43 print("XXX : ", ligne.find('Done processing '))
46 if ligne.find('Done processing ') == -1 and ligne.find('Category ') == -1 and ligne.find('Total errors found: ') == -1:
47 raise Exception("Fichier de log mal formé")
49 ligne = fichier.readline()
57 for item in liste[2:]:
61 liste = [item1, item2, merge]
62 ligne = fichier.readline()
64 yield liste[0], int(liste[1]), liste[2]
66 def get_src_path(path):
67 return os.path.normpath(os.path.join(SHAPER_SRC, path))
69 def get_line_no(path, nol):
70 """retourne la ligne No nol du fichier path (relatif à DST_SRC_PARENT) sous forme d'un unicode"""
72 fic = open(get_src_path(path), "r")
74 ligne = fic .readline()
76 ligne_u = ligne.decode(ENCODING)
79 def fic_readlines(fic):
83 liste.append(ligne.decode(ENCODING))
86 def fic_writelines(liste):
89 liste2.append(ligne.encode(ENCODING))