# 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

    def __init__(self, config, local_config):
        super(WebsocketLegacyInput, self).__init__(config, local_config)
        self.component = WebsocketConsumerCarriage()
        self.backend.register_component_start(self)

    def start(self):
        self._backend_consumer = self.backend.wsl_backend_consumer(uri=self.config.uri, custom_consumer=self.component)


class WebsocketBase(ConfigurableComponent):

    required_config = Namespace()
    required_config.add_option(
        'listen',
        default=None,
        doc='Socket to listen on i.e: ws://ADDR:PORT',
        from_string_converter=str_to_url_converter
    )
    required_config.add_option('connect', default=[], doc='List of connections to make')
    required_config.add_option(
        'proxy',
        doc='HTTP proxy in format ADDR:PORT',
        default=None,
        from_string_converter=parse_proxy_address
    )


class WebsocketOutput(WebsocketBase):


# 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


    def __init__(self, config, local_config):
        super(WebsocketLegacyInput, self).__init__(config, local_config)
        self.component = WebsocketConsumerCarriage()
        self.backend.register_component_start(self)

    def start(self):
        self._backend_consumer = self.backend.wsl_backend_consumer(uri=self.config.uri, custom_consumer=self.component)


class WebsocketBase(ConfigurableComponent):

    required_config = Namespace()
    required_config.add_option(
        'listen',
        default=None,
        doc='Socket to listen on i.e: ws://ADDR:PORT',
        from_string_converter=str_to_url_converter
    )
    required_config.add_option('connect', default=[], doc='List of connections to make')
    required_config.add_option(
        'proxy',
        doc='HTTP proxy in format ADDR:PORT',
        default=None,
        from_string_converter=parse_proxy_address
    )


class WebsocketOutput(WebsocketBase):


    required_config = Namespace()