# Path: grafana_dashboards/common.py
# def get_component_type(clazz):
#     """
# 
#     :type clazz: type
#     """
#     return _all_cap_re.sub(r'\1-\2', _first_cap_re.sub(r'\1-\2', clazz.__name__)).lower()
# 
# Path: grafana_dashboards/components/base.py
# class JsonListGenerator(JsonGenerator):
#     def __init__(self, data, registry, item_base_class):
#         super(JsonListGenerator, self).__init__(data, registry)
#         self.component_item_types = [get_component_type(clazz) for clazz in _get_subclasses(item_base_class)]
# 
#     def gen_json_from_data(self, data, context):
#         super(JsonListGenerator, self).gen_json_from_data(data, context)
#         result_list = []
#         for items in data:
#             self.gen_item_json(items, result_list)
#         return result_list
# 
#     def gen_item_json(self, items, result_list):
#         if isinstance(items, basestring):
#             # this is component without context
#             result_list += self.registry.get_component(type(self), items).gen_json()
#         else:
#             self._gen_item_json_with_context(items, result_list)
# 
#     def _gen_item_json_with_context(self, items, result_list):
#         # TODO add check for dictionary
#         for (item_type, item_data) in items.items():
#             if item_type not in self.component_item_types:
#                 # this is named component with context
#                 for context in Context.create_context(item_data, get_placeholders(item_type)):
#                     result_list += self.registry.get_component(type(self), item_type).gen_json(context)
#             else:
#                 # this is inplace defined component
#                 item = self.registry.create_component(item_type, {item_type: item_data}).gen_json()
#                 if isinstance(item, list):
#                     result_list += item
#                 else:
#                     result_list.append(item)
# 
# class JsonGenerator(ComponentBase):
# 
#     _copy_fields = set()
# 
#     def gen_json(self, context=Context()):
#         return self.gen_json_from_data(context.expand_placeholders(self.data), context)
# 
#     def gen_json_from_data(self, data, context):
#         component_type = get_component_type(type(self))
#         if self.name:
#             logger.debug("Processing component '%s' with name '%s' from template '%s'",
#                          component_type, context.expand_placeholders(self.name), self.name)
#         else:
#             logger.debug("Processing anonymous component '%s'", component_type)
#         json = {}
#         for field in self._copy_fields:
#             if field in data:
#                 json[field] = data[field]
#         return json
# 
# Path: grafana_dashboards/errors.py
# class UnregisteredComponentError(DashboardBuilderException):
#     pass


from grafana_dashboards.common import get_component_type
from grafana_dashboards.components.base import JsonListGenerator, JsonGenerator
from grafana_dashboards.errors import UnregisteredComponentError
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import unicode_literals


try:
    basestring
except NameError:
    basestring = str

__author__ = 'Jakub Plichta <jakub.plichta@gmail.com>'


class Targets(JsonListGenerator):
    def __init__(self, data, registry):
        super(Targets, self).__init__(data, registry, TargetsItemBase)

    def gen_item_json(self, items, result_list):
        try:
            super(Targets, self).gen_item_json(items, result_list)
        except UnregisteredComponentError:

# Path: grafana_dashboards/common.py
# def get_component_type(clazz):
#     """
# 
#     :type clazz: type
#     """
#     return _all_cap_re.sub(r'\1-\2', _first_cap_re.sub(r'\1-\2', clazz.__name__)).lower()
# 
# Path: grafana_dashboards/components/base.py
# class JsonListGenerator(JsonGenerator):
#     def __init__(self, data, registry, item_base_class):
#         super(JsonListGenerator, self).__init__(data, registry)
#         self.component_item_types = [get_component_type(clazz) for clazz in _get_subclasses(item_base_class)]
# 
#     def gen_json_from_data(self, data, context):
#         super(JsonListGenerator, self).gen_json_from_data(data, context)
#         result_list = []
#         for items in data:
#             self.gen_item_json(items, result_list)
#         return result_list
# 
#     def gen_item_json(self, items, result_list):
#         if isinstance(items, basestring):
#             # this is component without context
#             result_list += self.registry.get_component(type(self), items).gen_json()
#         else:
#             self._gen_item_json_with_context(items, result_list)
# 
#     def _gen_item_json_with_context(self, items, result_list):
#         # TODO add check for dictionary
#         for (item_type, item_data) in items.items():
#             if item_type not in self.component_item_types:
#                 # this is named component with context
#                 for context in Context.create_context(item_data, get_placeholders(item_type)):
#                     result_list += self.registry.get_component(type(self), item_type).gen_json(context)
#             else:
#                 # this is inplace defined component
#                 item = self.registry.create_component(item_type, {item_type: item_data}).gen_json()
#                 if isinstance(item, list):
#                     result_list += item
#                 else:
#                     result_list.append(item)
# 
# class JsonGenerator(ComponentBase):
# 
#     _copy_fields = set()
# 
#     def gen_json(self, context=Context()):
#         return self.gen_json_from_data(context.expand_placeholders(self.data), context)
# 
#     def gen_json_from_data(self, data, context):
#         component_type = get_component_type(type(self))
#         if self.name:
#             logger.debug("Processing component '%s' with name '%s' from template '%s'",
#                          component_type, context.expand_placeholders(self.name), self.name)
#         else:
#             logger.debug("Processing anonymous component '%s'", component_type)
#         json = {}
#         for field in self._copy_fields:
#             if field in data:
#                 json[field] = data[field]
#         return json
# 
# Path: grafana_dashboards/errors.py
# class UnregisteredComponentError(DashboardBuilderException):
#     pass


# Path: grafana_dashboards/components/targets.py
from grafana_dashboards.common import get_component_type
from grafana_dashboards.components.base import JsonListGenerator, JsonGenerator
from grafana_dashboards.errors import UnregisteredComponentError

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import unicode_literals


try:
    basestring
except NameError:
    basestring = str

__author__ = 'Jakub Plichta <jakub.plichta@gmail.com>'


class Targets(JsonListGenerator):
    def __init__(self, data, registry):
        super(Targets, self).__init__(data, registry, TargetsItemBase)

    def gen_item_json(self, items, result_list):
        try:
            super(Targets, self).gen_item_json(items, result_list)
        except UnregisteredComponentError:

            result_list.append(