<commit_before>#!/usr/bin/env python
"""Update example in readme."""

try:
    from cStringIO import StringIO
except ImportError:
    try:
        from StringIO import StringIO
    except ImportError:
        from io import StringIO


def split_readme(readme_path, before_key, after_key, end_key):
    """Return split readme."""
    with open(readme_path) as readme_file:
        readme = readme_file.read()

    top, rest = readme.split(before_key)
    before, rest = rest.split(after_key)
    _, bottom = rest.split(end_key)

    return (top.rstrip('\n'),
            before.strip('\n'),
            end_key + '\n\n' + bottom.lstrip('\n'))


def run_autopep8(source, options=()):
    """Return source code formatted with autopep8."""
    import tempfile
    temp = tempfile.mkstemp(dir='.')
    with open(temp[1], 'w') as temp_file:
        temp_file.write(source)

    try:
        import autopep8
        opts, _ = autopep8.parse_args(list(options) + [temp[1]])
        sio = StringIO()
        autopep8.fix_file(filename=temp[1],
                          opts=opts,
                          output=sio)
        output = sio.getvalue()
        if source.strip() and not output.strip():
            raise ValueError('autopep8 failed')
        return output
    finally:
        import os
        os.remove(temp[1])


def indent_line(line):
    """Indent non-empty lines."""
    if line:
        return 4 * ' ' + line
    else:
        return line


def indent(text):
    """Indent text by four spaces."""<commit_msg>Simplify<commit_after>#!/usr/bin/env python
"""Update example in readme."""


def split_readme(readme_path, before_key, after_key, end_key):
    """Return split readme."""
    with open(readme_path) as readme_file:
        readme = readme_file.read()

    top, rest = readme.split(before_key)
    before, rest = rest.split(after_key)
    _, bottom = rest.split(end_key)

    return (top.rstrip('\n'),
            before.strip('\n'),
            end_key + '\n\n' + bottom.lstrip('\n'))


def run_autopep8(source, options=()):
    """Return source code formatted with autopep8."""
    import tempfile
    temp = tempfile.mkstemp(dir='.')
    with open(temp[1], 'w') as temp_file:
        temp_file.write(source)

    try:
        import autopep8
        opts, _ = autopep8.parse_args(list(options) + [temp[1]])
        import io
        sio = io.StringIO()
        autopep8.fix_file(filename=temp[1],
                          opts=opts,
                          output=sio)
        output = sio.getvalue()
        if source.strip() and not output.strip():
            raise ValueError('autopep8 failed')
        return output
    finally:
        import os
        os.remove(temp[1])


def indent_line(line):
    """Indent non-empty lines."""
    if line:
        return 4 * ' ' + line
    else:
        return line


def indent(text):
    """Indent text by four spaces."""
{'fraction_non_alphanumeric': 0.1295784381478922, 'fraction_numerical': 0.007601935038009675, 'mean_word_length': 2.2711864406779663, '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': '2176064', 'n_tokens_mistral': 934, 'n_tokens_neox': 923, 'n_words': 219}