def get_module(filename_with_path):
"""
Given a filename with an absolute path, load the contents, instantiate a Module, and set the Module's path
attribute.
Parameters:
filename_with_path (str): the YAML filename with an absolute path
"""
try:
with open(filename_with_path) as config_file:
Module.temp_path = filename_with_path
this_module = yaml.load(config_file, Loader=Loader)
Module.temp_path = ""
return this_module
except IOError:
raise ModulePathError(filename_with_path)
except yaml.scanner.ScannerError:
raise ModuleConstraintParseError("Parsing of module {} failed. This is likely caused by a typo in the file."
"".format(filename_with_path))
# Add the YAML Module constructor so that YAML knows to use it in situations where the tag matches.
评论列表
文章目录