Salome HOME
pas de sens de filtrer si groupe actig
[tools/eficas.git] / Editeur / listePatrons.py
1 # Copyright (C) 2007-2021   EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 from __future__ import absolute_import
20 try :
21     from builtins import object
22 except : pass
23 import os
24 import re
25
26 sous_menus={
27 #           "OPENTURNS_STUDY" : {0:{"Essai":"Std.comm"}},
28 #            "OPENTURNS_WRAPPER" : {0:{"Essai":"wrapper_exemple.comm"}},
29            }
30
31 class listePatrons(object) :
32
33     def __init__(self,code = "ASTER"):
34         repIni=os.path.dirname(os.path.abspath(__file__))
35         self.rep_patrons=repIni+"/Patrons/"+code
36         self.sous_menu={}
37         if code in sous_menus  :
38             self.sous_menu=sous_menus[code]
39         self.code=code
40         self.liste={}
41         self.traiteListe()
42
43     def traiteListe(self):
44         if not (self.code in sous_menus) : return
45         if not (os.path.exists(self.rep_patrons)) : return
46         for file in os.listdir(self.rep_patrons):
47             for i in range(len(self.sous_menu)):
48                 clef=list(self.sous_menu[i].keys())[0]
49                 chaine=self.sous_menu[i][clef]
50                 if re.search(chaine,file) :
51                     if clef in self.liste:
52                         self.liste[clef].append(file)
53                     else :
54                         self.liste[clef]=[file]
55                     break