# 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




class FeatureBroker:
    def __init__(self, allow_replace=False):
        self.providers = {}
        self.tagged_features = {}
        self.tags = {}
        self.initialized = {}
        self.allow_replace = allow_replace

    def _parse_config(self):
        if 'xbmcaddon' in sys.modules:
            features_path = os.path.join(xbmcaddon.Addon().getAddonInfo('path'), 'resources/lib/config/features.yml')
        else:
            features_path = 'resources/lib/config/features.yml'

        with open(features_path) as config:
            feature_objects = []
            service_definitions = yaml.safe_load(config)

            for _service in service_definitions['services']:

# 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





class FeatureBroker:
    def __init__(self, allow_replace=False):
        self.providers = {}
        self.tagged_features = {}
        self.tags = {}
        self.initialized = {}
        self.allow_replace = allow_replace

    def _parse_config(self):
        if 'xbmcaddon' in sys.modules:
            features_path = os.path.join(xbmcaddon.Addon().getAddonInfo('path'), 'resources/lib/config/features.yml')
        else:
            features_path = 'resources/lib/config/features.yml'

        with open(features_path) as config:
            feature_objects = []
            service_definitions = yaml.safe_load(config)

            for _service in service_definitions['services']:

                feature = Component.from_dict(_service, **service_definitions['services'][_service])