def load_file(input_file, lib_to_use):
try:
with open(input_file) as data_file:
if lib_to_use == 'yaml':
output_file = yaml.safe_load(data_file)
elif lib_to_use == 'yaml_multi':
output_file = []
for doc in yaml.safe_load_all(data_file):
output_file.append(doc)
return output_file
except Exception as ex:
print "Unable to load file: " + input_file + "\nException information:\n" + str(ex.args)
sys.exit("Unable to load file: " + input_file)
评论列表
文章目录