# Path: ebu_tt_live/strings.py
# ERR_CONF_ONE_BACKEND_ONLY = gettext('There is only one backend allowed. Already created: {backend1}, New: {backend2}')
# 
# Path: ebu_tt_live/errors.py
# class ConfigurationError(Exception):
#     pass


import re
import six
import logging
import time
from configman import RequiredConfig, Namespace, converters
from ebu_tt_live.strings import ERR_CONF_ONE_BACKEND_ONLY
from ebu_tt_live.errors import ConfigurationError

runtime_template_regex = re.compile(ur'[*]{2}.*?[*]{2}')
converters = converters

log = logging.getLogger(__name__)


class ConfigurableComponent(RequiredConfig):

    required_config = Namespace()

    config = None
    component = None  # To store the component itself inside its configurator
    _backend = None  # Static variable holding the backend

    def __init__(self, config, local_config, backend=None):
        self.config = local_config

        if backend is not None:
            if self.backend is not None:
                raise ConfigurationError(
                    ERR_CONF_ONE_BACKEND_ONLY.format(
                        backend1=self.backend,
                        backend2=backend
                    )
                )
            else:

# Path: ebu_tt_live/strings.py
# ERR_CONF_ONE_BACKEND_ONLY = gettext('There is only one backend allowed. Already created: {backend1}, New: {backend2}')
# 
# Path: ebu_tt_live/errors.py
# class ConfigurationError(Exception):
#     pass


# Path: ebu_tt_live/config/common.py
import re
import six
import logging
import time
from configman import RequiredConfig, Namespace, converters
from ebu_tt_live.strings import ERR_CONF_ONE_BACKEND_ONLY
from ebu_tt_live.errors import ConfigurationError


runtime_template_regex = re.compile(ur'[*]{2}.*?[*]{2}')
converters = converters

log = logging.getLogger(__name__)


class ConfigurableComponent(RequiredConfig):

    required_config = Namespace()

    config = None
    component = None  # To store the component itself inside its configurator
    _backend = None  # Static variable holding the backend

    def __init__(self, config, local_config, backend=None):
        self.config = local_config

        if backend is not None:
            if self.backend is not None:
                raise ConfigurationError(
                    ERR_CONF_ONE_BACKEND_ONLY.format(
                        backend1=self.backend,
                        backend2=backend
                    )
                )
            else:

                ConfigurableComponent._backend = backend