Salome HOME
reindent + copyright + merge manuel avec la V9_dev sauf repertoires metier
[tools/eficas.git] / Editeur / catadesc.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 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,ssCode=None, selectable = True, userName=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  ssCode: string
47         :param ssCode: scheme associated to this catalog (Map only)
48
49         :type  userName: string
50         :param userName: name of the catalog as it will appear in the list
51
52         :type  selectable: boolean
53         :param selectable: indicate if this catalog appears in the list.
54                            Setting this parameter to False is useful to keep
55                            old catalogs to edit existing files but to forbid
56                            to use them to create new files.
57
58
59
60
61         """
62
63         self.labelCode = labelCode
64         self.fichierCata = fichierCata
65         self.formatFichierOut = formatFichierOut
66         self.formatFichierIn = formatFichierIn
67         self.default = default
68         self.code = code
69         self.ssCode = ssCode
70         if userName is None:
71             self.userName = labelCode
72         else:
73             self.userName = userName
74         self.selectable = selectable
75
76
77     @staticmethod
78     def createFromTuple(cataTuple):
79         #print "Warning: Describing a catalog with a tuple is deprecated. " \
80         #      "Please create a CatalogDescription instance directly."
81         if cataTuple[0] == 'TELEMAC':
82             desc = CatalogDescription(code = cataTuple[0],
83                                       ssCode = cataTuple[1],
84                                       labelCode = cataTuple[0]+cataTuple[1],
85                                       fichierCata = cataTuple[2],
86                                       formatFichierOut = cataTuple[3],
87                                       formatFichierIn = cataTuple[4])
88             return desc
89         if cataTuple[0] == 'MAP' :
90             desc = CatalogDescription(code = cataTuple[0],
91                                    labelCode = cataTuple[1],
92                                    fichierCata = cataTuple[2],
93                                    ssCode      = cataTuple[3],
94                                    formatFichierOut = 'MAP',
95                                    formatFichierIn  = 'MAP')
96         elif len(cataTuple) == 4:
97             desc = CatalogDescription(code = cataTuple[0],
98                                    labelCode = cataTuple[1],
99                                    fichierCata = cataTuple[2],
100                                    formatFichierOut = cataTuple[3],
101                                    formatFichierIn  = 'python')
102         elif len(cataTuple) == 5 :
103             desc = CatalogDescription(code = cataTuple[0],
104                                    labelCode = cataTuple[1],
105                                    fichierCata = cataTuple[2],
106                                    formatFichierOut = cataTuple[3],
107                                    formatFichierIn  = cataTuple[4])
108         elif len(cataTuple) == 6 :
109             desc = CatalogDescription(code = cataTuple[0],
110                                    labelCode = cataTuple[1],
111                                    fichierCata = cataTuple[2],
112                                    formatFichierOut = cataTuple[3],
113                                    formatFichierIn  = cataTuple[4],
114                                    defaut=cataTuple[5])
115         else :
116             print ('pb a la description du catalogue avec les donnees')
117             print (cataTuple)
118             desc=None
119
120         return desc