1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from builtins import object
24 class CatalogDescription(object):
26 def __init__(self, labelCode, fichierCata, formatFichierOut = "python", formatFichierIn='python',
27 default = False, code = None,ssCode=None, selectable = True, userName=None):
29 This class can be used to describe an Eficas catalog.
31 :type labelCode: string
32 :param labelCode: unique labelCode for the catalog
34 :type fichierCata: string
35 :param fichierCata: path of the file containing the catalog itself
37 :type fileFormatOut: string
38 :param fileFormatOut: format of the files generated when using this catalog
40 :type default: boolean
41 :param default: indicate if this catalog is the default one (appear on the top of the catalogs list)
44 :param code: Used to indicate the code associated to this catalog
47 :param ssCode: scheme associated to this catalog (Map only)
49 :type userName: string
50 :param userName: name of the catalog as it will appear in the list
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.
63 self.labelCode = labelCode
64 self.fichierCata = fichierCata
65 self.formatFichierOut = formatFichierOut
66 self.formatFichierIn = formatFichierIn
67 self.default = default
71 self.userName = labelCode
73 self.userName = userName
74 self.selectable = selectable
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])
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],
116 print ('pb a la description du catalogue avec les donnees')