本文整理汇总了Python中config.Configuration.runs方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.runs方法的具体用法?Python Configuration.runs怎么用?Python Configuration.runs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Configuration
的用法示例。
在下文中一共展示了Configuration.runs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import runs [as 别名]
def load(self):
"""
Loads a config.json file and run a validation process.
If the configurations seem valid, returns Configuration object.
"""
util.set_working_directory()
# paths relatively to this script's location
schema_json = util.json_decode(self.schema_path)
if schema_json is None:
msg = "Problem has occurred during the decoding procedure" + \
" with the following file: " + self.schema_path + "."
logging.error(msg)
raise IOError(msg)
tools_json = util.json_decode(self.tools_path)
if tools_json is None:
msg = "Problem has occurred during the decoding procedure" + \
" with the following file: " + self.tools_path + "."
logging.error(msg)
raise IOError(msg)
try:
with open(self.config_path, mode="r") as file:
config_string = file.read()
decoder = json.JSONDecoder(object_pairs_hook=checking_hook)
config_json = decoder.decode(config_string)
except IOError:
msg = "The file does not exist or cannot be read:" + \
(os.path.split(self.config_path))[1]
logging.error(msg)
raise IOError(msg)
except ValueError as value_error:
msg = (os.path.split(self.config_path))[1] + " file is not valid"
logging.error(msg)
print(value_error)
raise ValidationError(msg)
except KeyError as k_error:
msg = "Duplicate key specified."
logging.error(msg)
print(k_error)
print("Modify: " + (os.path.split(self.config_path))[1])
raise ValidationError(msg)
valid = validation.is_valid_json(config_json, schema_json)
if not valid:
msg = "Validation failed for " + \
(os.path.split(self.config_path))[1] + "."
logging.error(msg)
raise ValidationError(msg)
config = Configuration()
config.iterations = config_json["IterationCount"]
config.runs = config_json["Runs"]
config.queries = config_json["Queries"]
config.scenarios = config_json["Scenarios"]
config.sizes = util.get_power_of_two(config_json["MinSize"], config_json["MaxSize"])
config.tools = config_json["Tools"]
config.optional_arguments = config_json["OptionalArguments"]
return config