<commit_before># -*- coding: utf-8 -*-
"""
:copyright: (c) 2012 - 2015 by <NAME> <<EMAIL>>
:license: MIT
"""
# TODO: unicode_literals
from __future__ import absolute_import, print_function

import codecs
import glob
import logging
import os.path
import os
import sys

import anytemplate.compat

try:
    from anyconfig.api import container, load
except ImportError:
    container = dict
    load = anytemplate.compat.json_load


LOGGER = logging.getLogger(__name__)


def get_output_stream(encoding=anytemplate.compat.ENCODING,
                      ostream=sys.stdout):
    """
    Get output stream take care of characters encoding correctly.

    :param ostream: Output stream (file-like object); sys.stdout by default
    :param encoding: Characters set encoding, e.g. UTF-8
    :return: sys.stdout can output encoded strings

    >>> get_output_stream("UTF-8")  # doctest: +ELLIPSIS
    <encodings.utf_8.StreamWriter ... at 0x...>
    """
    return codecs.getwriter(encoding)(ostream)


def get_input_stream(encoding=anytemplate.compat.ENCODING):
    """
    :param encoding: Chart sets encoding
    :return: sys.stdout can output encoded strings

    >>> _t = get_input_stream("UTF-8")
    """
    return codecs.getreader(encoding)(sys.stdin)


def uniq(items):
    """Remove duplicates in given list with its order kept.

    >>> uniq([])
    []
    >>> uniq([1, 4, 5, 1, 2, 3, 5, 10])
    [1, 4, 5, 2, 3, 10]
    """
    acc = items[:1]
    for item in items[1:]:
        if item not in acc:
            acc += [item]

    return acc


def chaincalls(callables, obj):
    """
    :param callables: callable objects to apply to obj in this order
    :param obj: Object to apply callables

    >>> chaincalls([lambda a: a + 1, lambda b: b + 2], 0)
    3
    """
    for fun in callables:<commit_msg>refactor: check failure case of .utils.chaincalls<commit_after># -*- coding: utf-8 -*-
"""
:copyright: (c) 2012 - 2015 by <NAME> <<EMAIL>>
:license: MIT
"""
# TODO: unicode_literals
from __future__ import absolute_import, print_function

import codecs
import glob
import logging
import os.path
import os
import sys

import anytemplate.compat

try:
    from anyconfig.api import container, load
except ImportError:
    container = dict
    load = anytemplate.compat.json_load


LOGGER = logging.getLogger(__name__)


def get_output_stream(encoding=anytemplate.compat.ENCODING,
                      ostream=sys.stdout):
    """
    Get output stream take care of characters encoding correctly.

    :param ostream: Output stream (file-like object); sys.stdout by default
    :param encoding: Characters set encoding, e.g. UTF-8
    :return: sys.stdout can output encoded strings

    >>> get_output_stream("UTF-8")  # doctest: +ELLIPSIS
    <encodings.utf_8.StreamWriter ... at 0x...>
    """
    return codecs.getwriter(encoding)(ostream)


def get_input_stream(encoding=anytemplate.compat.ENCODING):
    """
    :param encoding: Chart sets encoding
    :return: sys.stdout can output encoded strings

    >>> _t = get_input_stream("UTF-8")
    """
    return codecs.getreader(encoding)(sys.stdin)


def uniq(items):
    """Remove duplicates in given list with its order kept.

    >>> uniq([])
    []
    >>> uniq([1, 4, 5, 1, 2, 3, 5, 10])
    [1, 4, 5, 2, 3, 10]
    """
    acc = items[:1]
    for item in items[1:]:
        if item not in acc:
            acc += [item]

    return acc


def chaincalls(callables, obj):
    """
    :param callables: callable objects to apply to obj in this order
    :param obj: Object to apply callables

    >>> chaincalls([lambda a: a + 1, lambda b: b + 2], 0)
    3
    >>> chaincalls([[]], 0)
    Traceback (most recent call last):
    ValueError: Not callable: '[]'
    """
    for fun in callables:
{'fraction_non_alphanumeric': 0.12266666666666666, 'fraction_numerical': 0.019466666666666667, 'mean_word_length': 3.0595238095238093, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 44, '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': '469673', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1163, 'n_words': 376}