# Path: resources/lib/di/component.py
# class Component(yaml.YAMLObject):
#     """Symbolic base class for components"""
#     yaml_tag = u'!component'
# 
#     def __init__(self, name, module, class_name, arguments, tags, factory_class, factory_method, lazy, calls):
#         self.name = name
#         self.module = module
#         self.class_name = class_name
#         self.arguments = arguments
#         self.tags = tags
#         self.factory_class = factory_class
#         self.factory_method = factory_method
#         self.lazy = lazy
#         self.calls = calls
# 
#     @classmethod
#     def from_dict(cls, name, module=None, class_name=None, arguments=None, tags=None, factory_class=None,
#                   factory_method=None, lazy=None, calls=None, **kwargs):
#         return cls(name, module, class_name, arguments, tags, factory_class, factory_method, lazy, calls)
# 
# Path: resources/lib/di/tag.py
# class Tag(object):
#     def __init__(self, name, **kwargs):
#         self.name = name
# 
#         for key, value in kwargs.iteritems():
#             self.__setattr__(key, value)
# 
#     @classmethod
#     def from_dict(cls, name, **kwargs):
#         return cls(name, **kwargs)
# 
#     def __str__(self):
#         if hasattr(self, 'channel'):
#             return '%s->%s' % (self.name, self.channel)
#         else:
#             return self.name


import importlib
import os
import sys
import yaml
import xbmcaddon
from resources.lib.di.component import Component
from resources.lib.di.tag import Tag
                from resources.lib.di.requiredfeature import RequiredFeature
                                from resources.lib.di.requiredfeature import RequiredFeature
        # Building tags as list is useful for services like @logger
        if tag.name not in self.tags:
            self.tags[tag.name] = []

        # Don't add tags multiple times
        if tag not in self.tags[tag.name]:
            self.tags[tag.name].append(tag)

        if feature not in self.tagged_features[tag.name]:
            self.tagged_features[tag.name].append(feature)

    def get_tagged_features(self, tag_name):
        try:
            tagged_features = self.tagged_features[tag_name]
        except KeyError:
            raise KeyError("Unknown tag named: %s" % tag_name)

        return tagged_features

    def _provide_loggers(self):
        module = importlib.import_module('resources.lib.core.logger.loggerchain')
        class_name = 'LoggerChain'
        class_ = getattr(module, class_name)

        addon_id = xbmcaddon.Addon().getAddonInfo('id')

        for logger_definition in self.tags['logger']:
            logger_prefix = '%s.%s' % (addon_id, logger_definition.channel)
            _logger = class_(logger_prefix)


# Path: resources/lib/di/component.py
# class Component(yaml.YAMLObject):
#     """Symbolic base class for components"""
#     yaml_tag = u'!component'
# 
#     def __init__(self, name, module, class_name, arguments, tags, factory_class, factory_method, lazy, calls):
#         self.name = name
#         self.module = module
#         self.class_name = class_name
#         self.arguments = arguments
#         self.tags = tags
#         self.factory_class = factory_class
#         self.factory_method = factory_method
#         self.lazy = lazy
#         self.calls = calls
# 
#     @classmethod
#     def from_dict(cls, name, module=None, class_name=None, arguments=None, tags=None, factory_class=None,
#                   factory_method=None, lazy=None, calls=None, **kwargs):
#         return cls(name, module, class_name, arguments, tags, factory_class, factory_method, lazy, calls)
# 
# Path: resources/lib/di/tag.py
# class Tag(object):
#     def __init__(self, name, **kwargs):
#         self.name = name
# 
#         for key, value in kwargs.iteritems():
#             self.__setattr__(key, value)
# 
#     @classmethod
#     def from_dict(cls, name, **kwargs):
#         return cls(name, **kwargs)
# 
#     def __str__(self):
#         if hasattr(self, 'channel'):
#             return '%s->%s' % (self.name, self.channel)
#         else:
#             return self.name


# Path: resources/lib/di/featurebroker.py
import importlib
import os
import sys
import yaml
import xbmcaddon
from resources.lib.di.component import Component
from resources.lib.di.tag import Tag
                from resources.lib.di.requiredfeature import RequiredFeature
                                from resources.lib.di.requiredfeature import RequiredFeature

        # Building tags as list is useful for services like @logger
        if tag.name not in self.tags:
            self.tags[tag.name] = []

        # Don't add tags multiple times
        if tag not in self.tags[tag.name]:
            self.tags[tag.name].append(tag)

        if feature not in self.tagged_features[tag.name]:
            self.tagged_features[tag.name].append(feature)

    def get_tagged_features(self, tag_name):
        try:
            tagged_features = self.tagged_features[tag_name]
        except KeyError:
            raise KeyError("Unknown tag named: %s" % tag_name)

        return tagged_features

    def _provide_loggers(self):
        module = importlib.import_module('resources.lib.core.logger.loggerchain')
        class_name = 'LoggerChain'
        class_ = getattr(module, class_name)

        addon_id = xbmcaddon.Addon().getAddonInfo('id')

        for logger_definition in self.tags['logger']:
            logger_prefix = '%s.%s' % (addon_id, logger_definition.channel)
            _logger = class_(logger_prefix)


            logger_services = list(self.tagged_features['logger-chain'])