<commit_before># -*- coding: utf-8 -*-
# Copyright © 2011-2013 <NAME>
# See the LICENCE file for more informations

"""Common utilities for test cases"""

import kaoz.bot
import logging
import os
import sys

from .ircserver import IRCServerThread, logger as ircserver_logger

if sys.version_info < (3,):
    from ConfigParser import SafeConfigParser as ConfigParser
else:
    from configparser import ConfigParser

try:
    import unittest2 as unittest
except ImportError:
    import unittest


def get_local_conf(filename=None):
    """Load local configuration"""
    if not filename:
        filename = "kaoz.local.conf"
    path = os.path.join(os.path.dirname(__file__), filename)
    config = kaoz.bot.get_default_config()
    config.read(path)
    return config


def spawn_ircserver(config):
    """Spawn a local IRC server, with respect to given configuration"""
    server = config.get('irc', 'server')
    port = config.getint('irc', 'port')
    name = '%s.%d.localdomain' % (server, port)
    # TODO: SSL support<commit_msg>Do not import unused ConfigParser in common.py<commit_after># -*- coding: utf-8 -*-
# Copyright © 2011-2013 <NAME>
# See the LICENCE file for more informations

"""Common utilities for test cases"""

import kaoz.bot
import logging
import os

from .ircserver import IRCServerThread, logger as ircserver_logger

try:
    import unittest2 as unittest
except ImportError:
    import unittest


def get_local_conf(filename=None):
    """Load local configuration"""
    if not filename:
        filename = "kaoz.local.conf"
    path = os.path.join(os.path.dirname(__file__), filename)
    config = kaoz.bot.get_default_config()
    config.read(path)
    return config


def spawn_ircserver(config):
    """Spawn a local IRC server, with respect to given configuration"""
    server = config.get('irc', 'server')
    port = config.getint('irc', 'port')
    name = '%s.%d.localdomain' % (server, port)
    # TODO: SSL support
{'fraction_non_alphanumeric': 0.11071245515120451, 'fraction_numerical': 0.010763710917478216, 'mean_word_length': 3.8436724565756824, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3583680', 'n_tokens_mistral': 613, 'n_tokens_neox': 582, 'n_words': 189}