<commit_before>"""Script to change -v for an ack command to vack"""

import os
import re
import sys
import commands

def which_ack():
    ack = os.environ.get('ACK') or 'ack'
    if not ack or not os.path.isfile(ack):
        status, output = commands.getstatusoutput('which ack')
        if status != os.EX_OK:
            raise NotImplementedError('"which ack" failed: "%s"' % output)
        ack = output
    if not os.path.isfile(ack):
        raise NotImplementedError('"%s" is not a file' % ack)
    return ack

def main(args):
    if '-U' in sys.argv:
        import pudb
        pudb.set_trace()
    words = [which_ack()]
    for word in args:
        if re.match('-[a-uw-z]*[vV][a-uw-z]*', word):
            words[0] = 'vack'
            words.append(word)
        else:
            if ' ' in word:
                if ' $' in word:
                    words.append("'%s'" % word)
                else:
                    words.append('"%s"' % word)
            else:
                words.append(word)
    print ' '.join(words)<commit_msg>Consider documenting your function(s)<commit_after>"""Script to change -v for an ack command to vack"""

import os
import re
import sys
import commands

def assert_perl_script(path):
    """Raise errors if that path is not a perl script

    It is a perl script if it
        1. is a file, and
        2.a. has a '.pl' extension, or
        2.b. mentions 'perl' in first line
    """
    if not os.path.isfile(path):
        raise NotImplementedError('"%s" is not a file' % path)
    stem, ext = os.path.splitext(path)
    if ext == '.pl':
        return
    with open(path) as stream:
        if 'perl' in stream.readline():
            return
    raise NotImplementedError('%s is not a perl script' % path)


def which_ack():
    """Find the system 'ack' with which

    Should be a perl script
    """
    ack = os.environ.get('ACK') or 'ack'
    if not ack or not os.path.isfile(ack):
        status, output = commands.getstatusoutput('which ack')
        if status != os.EX_OK:
            raise NotImplementedError('"which ack" failed: "%s"' % output)
        ack = output
    assert_perl_script(ack)
    return ack

def main(args):
    """Run this script as a program"""
    if '-U' in sys.argv:
        import pudb
        pudb.set_trace()
    words = [which_ack()]
    for word in args:
        if re.match('-[a-uw-z]*[vV][a-uw-z]*', word):
            words[0] = 'vack'
            words.append(word)
        else:
            if ' ' in word:
                if ' $' in word:
                    words.append("'%s'" % word)
                else:
                    words.append('"%s"' % word)
            else:
                words.append(word)
    print ' '.join(words)
{'fraction_non_alphanumeric': 0.1295754026354319, 'fraction_numerical': 0.0018301610541727673, 'mean_word_length': 1.8557993730407523, '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': '5340377', 'n_tokens_mistral': 893, 'n_tokens_neox': 866, 'n_words': 268}