Salome HOME
report modif variees + patch CEA
[tools/eficas.git] / Editeur / catadesc.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2017   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 try :
21    from builtins import object
22 except : pass
23
24 class CatalogDescription(object):
25     
26     def __init__(self, labelCode, fichierCata, formatFichierOut = "python", formatFichierIn='python',
27                  default = False, code = None,ss_code=None,):
28         """
29         This class can be used to describe an Eficas catalog.
30
31         :type  labelCode: string
32         :param labelCode: unique labelCode for the catalog
33                 
34         :type  fichierCata: string
35         :param fichierCata: path of the file containing the catalog itself
36                 
37         :type  fileFormatOut: string
38         :param fileFormatOut: format of the files generated when using this catalog
39                 
40         :type  default: boolean
41         :param default: indicate if this catalog is the default one (appear on the top of the catalogs list)
42                 
43         :type  code: string
44         :param code: Used to indicate the code associated to this catalog
45                 
46         :type  ss_code: string
47         :param ss_code: scheme associated to this catalog (Map only)
48
49                 
50         """
51
52         self.labelCode = labelCode
53         self.fichierCata = fichierCata
54         self.formatFichierOut = formatFichierOut
55         self.formatFichierIn = formatFichierIn 
56         self.default = default
57         self.code = code
58
59     @staticmethod
60     def createFromTuple(cataTuple):
61         #print "Warning: Describing a catalog with a tuple is deprecated. " \
62         #      "Please create a CatalogDescription instance directly."
63         if cataTuple[0] == 'MAP' :
64            desc = CatalogDescription(code = cataTuple[0],
65                                   labelCode = cataTuple[1],
66                                   fichierCata = cataTuple[2],
67                                   ssCode      = cataTuple[3],
68                                   formatFichierOut = 'MAP',
69                                   formatFichierIn  = 'MAP')
70         elif len(cataTuple) == 4:
71            desc = CatalogDescription(code = cataTuple[0],
72                                   labelCode = cataTuple[1],
73                                   fichierCata = cataTuple[2],
74                                   formatFichierOut = cataTuple[3],
75                                   formatFichierIn  = 'python')
76         elif len(cataTuple) == 5 : 
77            desc = CatalogDescription(code = cataTuple[0],
78                                   labelCode = cataTuple[1],
79                                   fichierCata = cataTuple[2],
80                                   formatFichierOut = cataTuple[3],
81                                   formatFichierIn  = cataTuple[4])
82         elif len(cataTuple) == 6 : 
83            desc = CatalogDescription(code = cataTuple[0],
84                                   labelCode = cataTuple[1],
85                                   fichierCata = cataTuple[2],
86                                   formatFichierOut = cataTuple[3],
87                                   formatFichierIn  = cataTuple[4],
88                                   defaut=cataTuple[5])
89         else : 
90            print ('pb a la description du catalogue avec les donnees')
91            print (cataTuple)
92            desc=None
93         
94         return desc