X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fcommon%2Ftemplate_format.py;h=e1662ced167be9ea139e775d573533d6ae4df72b;hb=8f91b0a5c1f47953dd1a14541b71505dbf8f869a;hp=2deaf393cd388c4a3d46ea6c1c653872075538ed;hpb=791323df72d8bf4f4f4c32a1e7273721f2adc349;p=yardstick.git diff --git a/yardstick/common/template_format.py b/yardstick/common/template_format.py index 2deaf393c..e1662ced1 100644 --- a/yardstick/common/template_format.py +++ b/yardstick/common/template_format.py @@ -12,8 +12,10 @@ # yardstick: this file is copied from python-heatclient and slightly modified -import json +from __future__ import absolute_import + import yaml +from oslo_serialization import jsonutils if hasattr(yaml, 'CSafeLoader'): yaml_loader = yaml.CSafeLoader @@ -40,13 +42,13 @@ yaml_loader.add_constructor(u'tag:yaml.org,2002:timestamp', def parse(tmpl_str): - '''Takes a string and returns a dict containing the parsed structure. + """Takes a string and returns a dict containing the parsed structure. This includes determination of whether the string is using the JSON or YAML format. - ''' + """ if tmpl_str.startswith('{'): - tpl = json.loads(tmpl_str) + tpl = jsonutils.loads(tmpl_str) else: try: tpl = yaml.load(tmpl_str, Loader=yaml_loader)