try:
with open(filepath, 'r') as f:
- config = yaml.load(f)
+ config = yaml.safe_load(f)
# Handle TRex configuration
trex_config['trex_name'] = config["trex"]["hostname"]
def load_object_config_file (filepath):
try:
with open(filepath, 'r') as f:
- config = yaml.load(f)
+ config = yaml.safe_load(f)
return config
except Exception as inst:
print("\nBad configuration file provided: '{0}'\n".format(filepath))
try:
with open(filepath, 'r') as f:
- benchmark_config = yaml.load(f)
+ benchmark_config = yaml.safe_load(f)
except Exception as inst:
print("\nBad configuration file provided: '{0}'\n".format(filepath))
def load_yaml_to_obj(file_path):
try:
- return yaml.load(file(file_path, 'r'))
+ return yaml.safe_load(file(file_path, 'r'))
except yaml.YAMLError as e:
raise
except Exception as e:
def json_dict_to_txt_table(dict_yaml_file):
-
+
# table = Texttable(max_width=120)
with open(dict_yaml_file, 'r') as f:
- yaml_stream = yaml.load(f)
+ yaml_stream = yaml.safe_load(f)
for main_field, sub_key in yaml_stream.items():
- print main_field + ' field' '\n' + '~'*len(main_field+' field') + '\n'
+ print(main_field + ' field' '\n' + '~'*len(main_field+' field') + '\n')
field_data_rows = handle_data_items(sub_key)
table = Texttable(max_width=120)
table.add_rows(field_data_rows, header=False)
- print table.draw() + "\n"
+ print(table.draw() + "\n")
+
+
-
-
json_dict_to_txt_table("json_dictionary.yaml")
\ No newline at end of file
yaml_str = f.read()
try:
- objects = yaml.load(yaml_str)
+ objects = yaml.safe_load(yaml_str)
except yaml.parser.ParserError as e:
raise STLError(str(e))