Skip to content
Snippets Groups Projects
Commit 3e0eed49 authored by Stephen Finucane's avatar Stephen Finucane
Browse files

Defer loading PyYAML


Yet another library that's slow to import and is totally optional. Defer
loading this one also and speed up initial start time.

Change-Id: Ic694b4d36dbf7ce87bc8fe9a2f8b0597719418a1
Signed-off-by: default avatarStephen Finucane <sfinucan@redhat.com>
parent 68112188
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,6 @@
"""Output formatters using PyYAML.
"""
import yaml
from . import base
from cliff import columns
......@@ -25,6 +23,9 @@ class YAMLFormatter(base.ListFormatter, base.SingleFormatter):
pass
def emit_list(self, column_names, data, stdout, parsed_args):
# the yaml import is slow, so defer loading until we know we want it
import yaml
items = []
for item in data:
items.append(
......@@ -36,6 +37,9 @@ class YAMLFormatter(base.ListFormatter, base.SingleFormatter):
yaml.safe_dump(items, stream=stdout, default_flow_style=False)
def emit_one(self, column_names, data, stdout, parsed_args):
# the yaml import is slow, so defer loading until we know we want it
import yaml
for key, value in zip(column_names, data):
dict_data = {
key: (value.machine_readable()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment