1 #-*-coding:iso-8859-1-*-
2 # Copyright (C) 2010 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU 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
19 # Author : André RIBES (EDF R&D)
26 from daYacsSchemaCreator.infos_daComposant import *
30 logging.debug("Arguments are :" + str(args))
32 logging.fatal("Bad number of arguments: you have to provide two arguments (%d given)" % (len(args)))
35 def check_study(study_config):
37 logging.debug("[check_env] study_config : " + str(study_config))
40 if not isinstance(study_config, dict):
41 logging.fatal("Study configuration is not a dictionnary")
45 if "Name" not in study_config:
46 logging.fatal("Cannot found Name in the study configuration")
50 if "Algorithm" not in study_config:
51 logging.fatal("Cannot found Algorithm in the study configuration")
54 if study_config["Algorithm"] not in AssimAlgos:
55 logging.fatal("Algorithm provided is unknow : " + str(study_config["Algorithm"]) +
56 "\n You can choose between : " + str(AssimAlgos))
59 # Check if all the data is provided
60 for key in AlgoDataRequirements[study_config["Algorithm"]]:
61 if key not in study_config.keys():
62 logging.fatal("Cannot found " + key + " in your study configuration !" +
63 "\n This key is mandatory into a study with " + study_config["Algorithm"] + " algorithm." +
64 "\n " + study_config["Algorithm"] + " requirements are " + str(AlgoDataRequirements[study_config["Algorithm"]]))
68 for key in study_config.keys():
70 check_data(key, study_config[key])
72 def check_data(data_name, data_config):
74 logging.debug("[check_data] " + data_name)
75 data_name_data = "Data"
76 data_name_type = "Type"
77 data_name_from = "From"
79 if data_name_data not in data_config:
80 logging.fatal(data_name +" found but " + data_name_data +" is not defined in the study configuration !")
83 if data_name_type not in data_config:
84 logging.fatal(data_name +" found but " + data_name_type +" is not defined in the study configuration !")
87 if data_config[data_name_type] not in AssimType[data_name]:
88 logging.fatal(data_name_type + " defined in the study configuration does not have a correct type : " + str(data_config[data_name_type])
89 + "\n You can have : " + str(AssimType[data_name]))
91 if data_name_from not in data_config:
92 logging.fatal(data_name + " found but " + data_name_from + " is not defined in the study configuration !")
95 if data_config[data_name_from] not in FromNumpyList[data_config[data_name_type]]:
96 logging.fatal(data_name_from + " defined in the study configuration does not have a correct value : " + str(data_config[data_name_from])
97 + "\n You can have : " + str(FromNumpyList[data_config[data_name_type]]))