3 # Copyright (C) 2010-2012 CEA/DEN
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 def get_module_config(config, module_name, version):
23 for c in ".-": vv = vv.replace(c, "_") # substitute some character with _
24 full_module_name = module_name + '_' + vv
27 if full_module_name in config.MODULES:
28 # returns specific information for the given version
29 mod_info = config.MODULES[full_module_name]
31 elif module_name in config.MODULES:
32 # returns the generic information (given version not found)
33 mod_info = config.MODULES[module_name]
35 # merge opt_depend in depend
36 if mod_info is not None and 'opt_depend' in mod_info:
37 for depend in mod_info.opt_depend:
38 if depend in config.MODULES:
39 mod_info.depend.append(depend,'')
42 def get_modules_infos(lmodules, config):
45 version_mod = config.APPLICATION.modules[mod][0]
46 mod_info = get_module_config(config, mod, version_mod)
47 if mod_info is not None:
48 modules_infos.append((mod, mod_info))
50 msg = _("The %s module has no definition in the configuration.") % mod
51 raise src.SatException(msg)
55 def module_is_sample(module_info):
56 mtype = module_info.module_type
57 return mtype.lower() == 'sample'