# Path: ebu_tt_live/config/common.py
# class ConfigurableComponent(RequiredConfig):
#     def __init__(self, config, local_config, backend=None):
#     def backend(self):
#     def configure_component(cls, config, local_config, **kwargs):
#     def _resolve_runtime_variable_match(cls, matchobj):
#     def resolve_runtime_variables(cls, str_parameter):
#     def start(self):
#     def stop(self):
# def install_app(app_obj):
# 
# Path: ebu_tt_live/strings.py
# ERR_CONF_PROXY_CONF_VALUE = gettext('Failed to parse proxy config: {value}')
# 
# ERR_NO_SUCH_COMPONENT = gettext('No such component: {type_name}')
# 
# Path: ebu_tt_live/errors.py
# class ConfigurationError(Exception):
#     pass
# 
# Path: ebu_tt_live/strings.py
# CFG_FILENAME_PATTERN = gettext('{sequence_identifier}_{counter}.xml')
# 
# CFG_MESSAGE_PATTERN = gettext('{sequence_identifier}_msg_{counter}.xml')


from .common import ConfigurableComponent, Namespace
from ebu_tt_live.carriage.direct import DirectCarriageImpl
from ebu_tt_live.carriage.websocket import WebsocketProducerCarriage, WebsocketConsumerCarriage
from ebu_tt_live.carriage import filesystem
from ebu_tt_live.strings import ERR_CONF_PROXY_CONF_VALUE, ERR_NO_SUCH_COMPONENT
from ebu_tt_live.errors import ConfigurationError
from ebu_tt_live.strings import CFG_FILENAME_PATTERN, CFG_MESSAGE_PATTERN
import urlparse
import re
    _backend_consumer = None

    def __init__(self, config, local_config):
        super(WebsocketInput, self).__init__(config, local_config)
        # from_string_converter does not work for lists in configman :( Doing it manually here
        self.config.connect = parse_url_list(self.config.connect)
        self.component = WebsocketConsumerCarriage()
        self.backend.register_component_start(self)

    def start(self):
        self._backend_consumer = self.backend.ws_backend_consumer(
            custom_consumer=self.component,
            listen=self.config.listen,
            connect=self.config.connect,
            proxy=self.config.proxy
        )


producer_carriage_by_type = {
    'websocket': WebsocketOutput,
    'websocket-legacy': WebsocketLegacyOutput,
    'filesystem': FilesystemOutput,
    'direct': DirectOutput
}


def get_producer_carriage(carriage_type):
    try:
        return producer_carriage_by_type[carriage_type]
    except KeyError:

# Path: ebu_tt_live/config/common.py
# class ConfigurableComponent(RequiredConfig):
#     def __init__(self, config, local_config, backend=None):
#     def backend(self):
#     def configure_component(cls, config, local_config, **kwargs):
#     def _resolve_runtime_variable_match(cls, matchobj):
#     def resolve_runtime_variables(cls, str_parameter):
#     def start(self):
#     def stop(self):
# def install_app(app_obj):
# 
# Path: ebu_tt_live/strings.py
# ERR_CONF_PROXY_CONF_VALUE = gettext('Failed to parse proxy config: {value}')
# 
# ERR_NO_SUCH_COMPONENT = gettext('No such component: {type_name}')
# 
# Path: ebu_tt_live/errors.py
# class ConfigurationError(Exception):
#     pass
# 
# Path: ebu_tt_live/strings.py
# CFG_FILENAME_PATTERN = gettext('{sequence_identifier}_{counter}.xml')
# 
# CFG_MESSAGE_PATTERN = gettext('{sequence_identifier}_msg_{counter}.xml')


# Path: ebu_tt_live/config/carriage.py
from .common import ConfigurableComponent, Namespace
from ebu_tt_live.carriage.direct import DirectCarriageImpl
from ebu_tt_live.carriage.websocket import WebsocketProducerCarriage, WebsocketConsumerCarriage
from ebu_tt_live.carriage import filesystem
from ebu_tt_live.strings import ERR_CONF_PROXY_CONF_VALUE, ERR_NO_SUCH_COMPONENT
from ebu_tt_live.errors import ConfigurationError
from ebu_tt_live.strings import CFG_FILENAME_PATTERN, CFG_MESSAGE_PATTERN
import urlparse
import re

    _backend_consumer = None

    def __init__(self, config, local_config):
        super(WebsocketInput, self).__init__(config, local_config)
        # from_string_converter does not work for lists in configman :( Doing it manually here
        self.config.connect = parse_url_list(self.config.connect)
        self.component = WebsocketConsumerCarriage()
        self.backend.register_component_start(self)

    def start(self):
        self._backend_consumer = self.backend.ws_backend_consumer(
            custom_consumer=self.component,
            listen=self.config.listen,
            connect=self.config.connect,
            proxy=self.config.proxy
        )


producer_carriage_by_type = {
    'websocket': WebsocketOutput,
    'websocket-legacy': WebsocketLegacyOutput,
    'filesystem': FilesystemOutput,
    'direct': DirectOutput
}


def get_producer_carriage(carriage_type):
    try:
        return producer_carriage_by_type[carriage_type]
    except KeyError:

        raise ConfigurationError(