<commit_before># Copyright 2013 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import net.kuujo.vertigo.util.Context
import net.kuujo.vertigo.impl.DefaultVertigoFactory
import net.kuujo.vertigo.component.impl.DefaultComponentFactory
import org.vertx.java.platform.impl.JythonVerticleFactory
from context import NetworkContext, InstanceContext
from network import Network

this = sys.modules[__name__]

current_context = None
_context = net.kuujo.vertigo.util.Context.parseContext(org.vertx.java.platform.impl.JythonVerticleFactory.container.config())
if _context is not None:
    current_context = InstanceContext(_context)

def _setup_vertigo():
    vertx = org.vertx.java.platform.impl.JythonVerticleFactory.vertx
    container = org.vertx.java.platform.impl.JythonVerticleFactory.container
    factory = net.kuujo.vertigo.impl.DefaultVertigoFactory(vertx, container)
    if current_context is not None:
        component_factory = net.kuujo.vertigo.component.impl.DefaultComponentFactory(vertx, container)
        return factory.createVertigo(component_factory.createComponent(current_context._context))
    else:
        return factory.createVertigo()

_vertigo = _setup_vertigo()

def is_component():
    """
    Indicates whether the current verticle is a Vertigo component instance.

    @return: A boolean indicating whether the current Vert.x verticle is
    a Vertigo component instance.
    """
    return _vertigo.isComponent()

if _vertigo.isComponent():
    _component_type = net.kuujo.vertigo.util.Component.serializeType(_vertigo.context().getComponent().getType())
    if _component_type == 'feeder':
        from . import _feeder
        feeder = _feeder.Feeder(_vertigo.component()).start()
    elif _component_type == 'executor':
        from . import _executor
        executor = _executor.Executor(_vertigo.component()).start()
    elif _component_type == 'worker':
        from . import _worker
        worker = _worker.Worker(_vertigo.component()).start()
    else:
        raise ImportError("Unknown Vertigo component type %s" % (_component_type,))

logger = org.vertx.java.platform.impl.JythonVerticleFactory.container.logger()

def create_network(address):
    """
    Creates a new network.<commit_msg>Refactor Vertigo/component construction to use new static Vertigo factory methods.<commit_after># Copyright 2013 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import net.kuujo.vertigo.util.Factory
import net.kuujo.vertigo.util.Component
import org.vertx.java.platform.impl.JythonVerticleFactory
from context import NetworkContext, InstanceContext
from network import Network

this = sys.modules[__name__]

_vertigo = net.kuujo.vertigo.util.Factory.createVertigo(org.vertx.java.platform.impl.JythonVerticleFactory.vertx, org.vertx.java.platform.impl.JythonVerticleFactory.container)

logger = org.vertx.java.platform.impl.JythonVerticleFactory.container.logger()

# Note: This method must come before the component module is imported
# due to a recursive dependency.
def is_component():
    """
    Indicates whether the current verticle is a Vertigo component instance.

    @return: A boolean indicating whether the current Vert.x verticle is
    a Vertigo component instance.
    """
    return _vertigo.isComponent()

current_context = None
if is_component():
    current_context = InstanceContext(_vertigo.context())
    _component_type = net.kuujo.vertigo.util.Component.serializeType(_vertigo.context().getComponent().getType())
    if _component_type == 'feeder':
        from . import _feeder
        feeder = _feeder.Feeder(_vertigo.component()).start()
    elif _component_type == 'executor':
        from . import _executor
        executor = _executor.Executor(_vertigo.component()).start()
    elif _component_type == 'worker':
        from . import _worker
        worker = _worker.Worker(_vertigo.component()).start()
    else:
        raise ImportError("Unknown Vertigo component type %s" % (_component_type,))

def create_network(address):
    """
    Creates a new network.
{'fraction_non_alphanumeric': 0.08868441660140955, 'fraction_numerical': 0.0031323414252153485, 'mean_word_length': 4.28335056876939, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3384738', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1395, 'n_words': 422}