<commit_before>import io
import functools
import warnings
import six

from .decoder import LabelDecoder
from .encoder import LabelEncoder


def load(stream):
    """Parse an isis label from a stream.

    :param stream: a ``.read()``-supporting file-like object containing a label.
        if ``stream`` is a string it will be treated as a filename
    """
    if isinstance(stream, six.string_types):
        with open(stream, 'rb') as fp:
            return LabelDecoder().decode(fp)
    return LabelDecoder().decode(stream)


def loads(data, encoding='utf-8'):
    """Parse an isis label from a string.

    :param data: an isis label as a string

    :returns: a dictionary representation of the given isis label
    """
    if not isinstance(data, bytes):
        data = data.encode(encoding)
    return LabelDecoder().decode(data)


def dump(label, stream):
    LabelEncoder().encode(label, stream)


def dumps(label):
    stream = io.BytesIO()
    LabelEncoder().encode(label, stream)
    return stream.getvalue()


@functools.wraps(load)
def parse_file_label(stream):
    warnings.warn('parse_file_label is deprecated. use load instead.')
    return load(stream)


@functools.wraps(loads)
def parse_label(data, encoding='utf-8'):
    warnings.warn('parse_label is deprecated. use load instead.')
    return loads(data, encoding='utf-8')<commit_msg>Add depreciation messages to old parse_label methods.<commit_after>import io
import warnings
import six

from .decoder import LabelDecoder
from .encoder import LabelEncoder


def load(stream):
    """Parse an isis label from a stream.

    :param stream: a ``.read()``-supporting file-like object containing a label.
        if ``stream`` is a string it will be treated as a filename
    """
    if isinstance(stream, six.string_types):
        with open(stream, 'rb') as fp:
            return LabelDecoder().decode(fp)
    return LabelDecoder().decode(stream)


def loads(data, encoding='utf-8'):
    """Parse an isis label from a string.

    :param data: an isis label as a string

    :returns: a dictionary representation of the given isis label
    """
    if not isinstance(data, bytes):
        data = data.encode(encoding)
    return LabelDecoder().decode(data)


def dump(label, stream):
    LabelEncoder().encode(label, stream)


def dumps(label):
    stream = io.BytesIO()
    LabelEncoder().encode(label, stream)
    return stream.getvalue()


def parse_file_label(stream):
    load.__doc__ + """
    deprecated:: 0.4.0
    Use load instead.
    """
    warnings.warn('parse_file_label is deprecated. use load instead.')
    return load(stream)


def parse_label(data, encoding='utf-8'):
    loads.__doc__ + """
    deprecated:: 0.4.0
    Use loads instead.
    """
    warnings.warn('parse_label is deprecated. use loads instead.')
    return loads(data, encoding='utf-8')
{'fraction_non_alphanumeric': 0.1136123812873725, 'fraction_numerical': 0.004220893422441084, 'mean_word_length': 3.457680250783699, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3677601', 'n_tokens_mistral': 841, 'n_tokens_neox': 820, 'n_words': 273}