<commit_before>#!/usr/bin/env python

import sys
import subprocess
import tempfile
import shutil

placeholder="@"

def main():
    command = sys.argv[2:]
    filename = sys.argv[1]

    # Get the actual command to run
    if placeholder in command:
        command = [arg if arg!=placeholder else filename
                   for arg in command]
        
        command = [(arg, filename)[arg!=placeholder]
                   for arg in command]
    else:
        command.append(placeholder)

    print "Running", command

    # Open a temporary file and run the command, redirecting output there
    with tempfile.NamedTemporaryFile(delete=False) as temp:
        ret = subprocess.call(command, stdout=temp, stderr=temp)

        output_filename = temp.name


    # Replace the original file
    if ret == 0:
        backup = filename + ".orig"
        shutil.movefile(filename, backup)

        shutil.movefile(output_filename, filename)
    else:
        print "Subcommand returned", ret
        print "Leaving", filename, "unchanged; the output is stored in", output_filename

    sys.exit(ret)


if __name__ == "__main__":
    main()
    <commit_msg>Couple fixes<commit_after>#!/usr/bin/env python

import sys
import subprocess
import tempfile
import shutil

placeholder="@"

def main():
    command = sys.argv[2:]
    filename = sys.argv[1]

    # Get the actual command to run
    if placeholder in command:
        command = [(arg, filename)[arg==placeholder]
                   for arg in command]
    else:
        command.append(filename)

    print "Running", command

    # Open a temporary file and run the command, redirecting output there
    with tempfile.NamedTemporaryFile(delete=False) as temp:
        ret = subprocess.call(command, stdout=temp, stderr=temp)

        output_filename = temp.name


    # Replace the original file
    if ret == 0:
        backup = filename + ".orig"
        shutil.move(filename, backup)

        shutil.move(output_filename, filename)
    else:
        print "Subcommand returned", ret
        print "Leaving", filename, "unchanged; the output is stored in", output_filename

    sys.exit(ret)


if __name__ == "__main__":
    main()
    
{'fraction_non_alphanumeric': 0.0925672594619243, 'fraction_numerical': 0.0027359781121751026, 'mean_word_length': 2.614497528830313, 'pattern_counts': {'":': 2, '<': 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': '7504857', 'n_tokens_mistral': 637, 'n_tokens_neox': 604, 'n_words': 199}