Salome HOME
cht version
[tools/eficas.git] / Editeur / analyse_catalogue_initial.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021   EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 from __future__ import absolute_import
21 from __future__ import print_function
22 try :
23     from builtins import str
24     from builtins import object
25 except :
26     pass
27 import re,os
28
29 from Extensions.i18n import tr
30 #
31 __Id__="$Id: analyseCatalogue_initial.py,v 1.2.4.1.2.2.2.4 2017-04-09 14:04:44 pnoyret Exp $"
32 __version__="$Name: V7_main $"
33 #
34
35
36 class Catalogue_initial(object):
37     def __init__(self,fichier):
38         self.liste_commandes=[]
39         self.lignes=[]
40         self.fichier=fichier
41         self.ouvrirFichier()
42         self.constrListTxtCmd()
43
44     def ouvrirFichier(self):
45         try :
46             with open(self.fichier) as fd:
47                 self.lignes=fd.readlines()
48         except :
49             print(tr("Impossible d'ouvrir le fichier : %s", str(self.fichier)))
50
51     def constrListTxtCmd(self):
52         pattern = '^# Ordre Catalogue '
53         for i in self.lignes :
54             if (re.search(pattern,i)):
55                 i=i.replace('# Ordre Catalogue ','')
56                 i=i.replace('\n','')
57                 self.liste_commandes.append(i)
58
59
60 def analyseCatalogue(nom_cata):
61     cata = Catalogue_initial(nom_cata)
62     return cata.liste_commandes
63
64
65 if __name__ == "__main__" :
66     monCata="/local/noyret/Install_Eficas/EficasQT4/Openturns_StudyOpenTURNS_Cata_Study_V4.py"
67     analyseCatalogue(monCata)