<commit_before>#!/usr/bin/env python
"""
Test that autopep8 runs without crashing on various Python files.
"""
import sys


def run(filename, log_file, report_incomplete_fix=False, passes=2000):
    """Run autopep8 on file at filename.
    Return True on success.
    """
    import os
    autopep8_path = os.path.split(os.path.abspath(
            os.path.dirname(__file__)))[0]
    autoppe8_bin = os.path.join(autopep8_path, 'autopep8.py')
    command = [autoppe8_bin, '--pep8-passes={p}'.format(p=passes),
               filename]

    import subprocess
    if report_incomplete_fix:
        import tempfile
        with tempfile.NamedTemporaryFile(suffix='.py') as f:
            if 0 != subprocess.call(command, stdout=f, stderr=log_file):
                log_file.write('autopep8 crashed on ' + filename + '\n')
                return False

            if 0 != subprocess.call(['pep8', '--ignore=E501',
                                     '--show-source', f.name],
                                    stderr=f):
                log_file.write('autopep8 did not completely fix ' +
                               filename + '\n')
    else:
        if 0 != subprocess.call(command + ['--diff'], stderr=log_file):
            log_file.write('autopep8 crashed on ' + filename + '\n')
            return False

    return True


def main():
    import optparse
    parser = optparse.OptionParser()
    parser.add_option('--report-incomplete-fix', action='store_true',
                      help='report incomplete PEP8 fixes')
    parser.add_option('--log-errors',
                      help='log autopep8 errors instead of exiting')
    opts, args = parser.parse_args()

    if opts.log_errors:
        log_file = open(opts.log_errors, 'w')
    else:
        log_file = sys.stderr

    try:
        import os
        for p in sys.path:
            for root, dirnames, filenames in os.walk(p):
                import fnmatch<commit_msg>Pass the same ignore option in acid test<commit_after>#!/usr/bin/env python
"""
Test that autopep8 runs without crashing on various Python files.
"""
import sys


def run(filename, log_file, report_incomplete_fix=False, passes=2000,
        ignore_list=['E501']):
    """Run autopep8 on file at filename.
    Return True on success.
    """
    ignore_option = '--ignore=' + ','.join(ignore_list)

    import os
    autopep8_path = os.path.split(os.path.abspath(
            os.path.dirname(__file__)))[0]
    autoppe8_bin = os.path.join(autopep8_path, 'autopep8.py')
    command = [autoppe8_bin, '--pep8-passes={p}'.format(p=passes),
               ignore_option, filename]

    import subprocess
    if report_incomplete_fix:
        import tempfile
        with tempfile.NamedTemporaryFile(suffix='.py') as f:
            if 0 != subprocess.call(command, stdout=f, stderr=log_file):
                log_file.write('autopep8 crashed on ' + filename + '\n')
                return False

            if 0 != subprocess.call(['pep8', ignore_option,
                                     '--show-source', f.name],
                                    stderr=f):
                log_file.write('autopep8 did not completely fix ' +
                               filename + '\n')
    else:
        if 0 != subprocess.call(command + ['--diff'], stderr=log_file):
            log_file.write('autopep8 crashed on ' + filename + '\n')
            return False

    return True


def main():
    import optparse
    parser = optparse.OptionParser()
    parser.add_option('--report-incomplete-fix', action='store_true',
                      help='report incomplete PEP8 fixes')
    parser.add_option('--log-errors',
                      help='log autopep8 errors instead of exiting')
    opts, args = parser.parse_args()

    if opts.log_errors:
        log_file = open(opts.log_errors, 'w')
    else:
        log_file = sys.stderr

    try:
        import os
        for p in sys.path:
            for root, dirnames, filenames in os.walk(p):
                import fnmatch
{'fraction_non_alphanumeric': 0.11616287784161879, 'fraction_numerical': 0.012490632025980514, 'mean_word_length': 1.999250936329588, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1915407', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1185, 'n_words': 285}