提交 9b1a04dc 编写于 作者: L Lukáš Doktor 提交者: Lucas Meneghel Rodrigues

avocado.core.tree: Use yaml.CLoader when available

CLoader is C (faster) version of the Loader. In case it's unavailable
it fall-backs automatically to the default Loader.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 8b7122f5
......@@ -37,6 +37,12 @@ import collections
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
class TreeNode(object):
def __init__(self, name='', value=None, parent=None, children=None):
......@@ -257,9 +263,9 @@ def _create_from_yaml(stream):
else: # Values
objects.append(Value((name, values)))
return objects
yaml.Loader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
mapping_to_tree_loader)
return tree_node_from_values('', yaml.load(stream, yaml.Loader))
Loader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
mapping_to_tree_loader)
return tree_node_from_values('', yaml.load(stream, Loader))
def create_from_yaml(fileobj):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册