Salome HOME
modif pour MT
[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, identifier, cata_file_path, file_format = "python",
27                  default = False, code = None,ss_code=None, user_name = None,
28                  selectable = True, file_format_in = "python"):
29         """
30         This class can be used to describe an Eficas catalog.
31
32         :type  identifier: string
33         :param identifier: unique identifier for the catalog
34                 
35         :type  cata_file_path: string
36         :param cata_file_path: path of the file containing the catalog itself
37                 
38         :type  file_format: string
39         :param file_format: format of the files generated when using this
40                             catalog
41                 
42         :type  default: boolean
43         :param default: indicate if this catalog is the default one (appear on
44                         the top of the catalogs list)
45                 
46         :type  code: string
47         :param code: Deprecated. Used to indicate the code associated to this
48                      catalog
49                 
50         :type  ss_code: string
51         :param ss_code: scheme associated to this catalog (Map only)
52
53         :type  user_name: string
54         :param user_name: name of the catalog as it will appear in the list
55                 
56         :type  selectable: boolean
57         :param selectable: indicate if this catalog appears in the list.
58                            Setting this parameter to False is useful to keep
59                            old catalogs to edit existing files but to forbid
60                            to use them to create new files.
61                 
62         """
63         self.identifier = identifier
64         self.cata_file_path = cata_file_path
65         self.file_format = file_format
66         self.default = default
67         self.code = code
68         if user_name is None:
69             self.user_name = identifier
70         else:
71             self.user_name = user_name
72         self.selectable = selectable
73         self.file_format_in = file_format_in
74
75     @staticmethod
76     def create_from_tuple(cata_tuple):
77         #print "Warning: Describing a catalog with a tuple is deprecated. " \
78         #      "Please create a CatalogDescription instance directly."
79         desc = CatalogDescription(code = cata_tuple[0],
80                                   identifier = cata_tuple[1],
81                                   cata_file_path = cata_tuple[2],
82                                   file_format = cata_tuple[3])
83         
84         if len(cata_tuple) == 5:
85             if cata_tuple[4] == "defaut":
86                 desc.default = True
87             else:
88                 desc.file_format_in = cata_tuple[4]
89         return desc