<commit_before>from __future__ import unicode_literals

import sys

from spotify import ffi, lib


PY2 = sys.version_info[0] == 2

if PY2:
    text_type = unicode
    binary_type = str
else:
    text_type = str
    binary_type = bytes


def enum(prefix):
    def wrapper(obj):
        for attr in dir(lib):
            if attr.startswith(prefix):
                setattr(obj, attr.replace(prefix, ''), getattr(lib, attr))
        return obj
    return wrapper


def get_with_growing_buffer(func, obj):
    actual_length = 10
    buffer_length = actual_length
    while actual_length >= buffer_length:
        buffer_length = actual_length + 1
        buffer_ = ffi.new('char[%d]' % buffer_length)
        actual_length = func(obj, buffer_, buffer_length)
    if actual_length == -1:
        return None
    return to_unicode(buffer_)


def to_bytes(value):<commit_msg>utils: Turn off branch coverage Python 2 vs 3 branches<commit_after>from __future__ import unicode_literals

import sys

from spotify import ffi, lib


PY2 = sys.version_info[0] == 2

if PY2:  # pragma: no branch
    text_type = unicode
    binary_type = str
else:
    text_type = str
    binary_type = bytes


def enum(prefix):
    def wrapper(obj):
        for attr in dir(lib):
            if attr.startswith(prefix):
                setattr(obj, attr.replace(prefix, ''), getattr(lib, attr))
        return obj
    return wrapper


def get_with_growing_buffer(func, obj):
    actual_length = 10
    buffer_length = actual_length
    while actual_length >= buffer_length:
        buffer_length = actual_length + 1
        buffer_ = ffi.new('char[%d]' % buffer_length)
        actual_length = func(obj, buffer_, buffer_length)
    if actual_length == -1:
        return None
    return to_unicode(buffer_)


def to_bytes(value):
{'fraction_non_alphanumeric': 0.08731924360400445, 'fraction_numerical': 0.010011123470522803, 'mean_word_length': 2.9023861171366594, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4179061', 'n_tokens_mistral': 586, 'n_tokens_neox': 555, 'n_words': 155}