# Path: vitrageclient/common/utils.py
# def args_to_dict(args, attrs):
# def list2cols(cols, objs):
# def list2cols_with_rename(names_and_keys, objs):
# def get_client(obj):
# def wait_for_action_to_end(timeout, func, **kwargs):
# def find_template_with_uuid(uuid, templates):
# 
# Path: vitrageclient/common/utils.py
# def find_template_with_uuid(uuid, templates):
#     return next(
#         (
#             template
#             for template in templates
#             if template['uuid'] == uuid
#         ), None
#     )


import sys
from cliff import command
from cliff import lister
from cliff import show
from oslo_log import log
from vitrageclient.common import utils
from vitrageclient.common.utils import find_template_with_uuid
            ), templates)

    def _check_finished_loading(self, templates):
        if all(
                (
                    template['status'] == 'ERROR'
                    for template in templates
                )
        ):
            return True

        try:
            api_templates = utils.get_client(self).template.list()
            self._update_templates_status(api_templates, templates)
            if any(
                    (
                        template['status'] == 'LOADING'
                        for template in templates
                    )
            ):
                return False
            return True
        except Exception:
            return True

    @staticmethod
    def _update_templates_status(api_templates, templates):
        for template in templates:
            uuid = template.get('uuid')
            if uuid:

# Path: vitrageclient/common/utils.py
# def args_to_dict(args, attrs):
# def list2cols(cols, objs):
# def list2cols_with_rename(names_and_keys, objs):
# def get_client(obj):
# def wait_for_action_to_end(timeout, func, **kwargs):
# def find_template_with_uuid(uuid, templates):
# 
# Path: vitrageclient/common/utils.py
# def find_template_with_uuid(uuid, templates):
#     return next(
#         (
#             template
#             for template in templates
#             if template['uuid'] == uuid
#         ), None
#     )


# Path: vitrageclient/v1/cli/template.py
import sys
from cliff import command
from cliff import lister
from cliff import show
from oslo_log import log
from vitrageclient.common import utils
from vitrageclient.common.utils import find_template_with_uuid

            ), templates)

    def _check_finished_loading(self, templates):
        if all(
                (
                    template['status'] == 'ERROR'
                    for template in templates
                )
        ):
            return True

        try:
            api_templates = utils.get_client(self).template.list()
            self._update_templates_status(api_templates, templates)
            if any(
                    (
                        template['status'] == 'LOADING'
                        for template in templates
                    )
            ):
                return False
            return True
        except Exception:
            return True

    @staticmethod
    def _update_templates_status(api_templates, templates):
        for template in templates:
            uuid = template.get('uuid')
            if uuid:

                api_template = find_template_with_uuid(uuid, api_templates)