<commit_before>"""Add things to old Pythons so I can pretend they are newer, for tests."""

# pylint: disable-msg=W0622
# (Redefining built-in blah)
# The whole point of this file is to redefine built-ins, so shut up about it.

import os, sys

# Py2k and 3k don't agree on how to run commands in a subprocess.
try:
    import subprocess
except ImportError:
    def run_command(cmd):
        """Run a command in a subprocess.

        Returns the exit code and the combined stdout and stderr.

        """
        _, stdouterr = os.popen4(cmd)
        return 0, stdouterr.read()
else:
    def run_command(cmd):
        """Run a command in a subprocess.

        Returns the exit code and the combined stdout and stderr.

        """

        if sys.hexversion > 0x03000000 and cmd.startswith("coverage "):
            # We don't have a coverage command on 3.x, so fix it up to call the
            # script. Eventually we won't need this.
            cmd = "python " + sys.prefix + os.sep + "Scripts" + os.sep + cmd

        proc = subprocess.Popen(cmd, shell=True,
                stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT
                )
        retcode = proc.wait()

        # Get the output, and canonicalize it to strings with newlines.
        output = proc.stdout.read()
        if not isinstance(output, str):
            output = output.decode('utf-8')
        output = output.replace('\r', '')

        return retcode, output

# No more execfile in Py3k
try:
    execfile = execfile
except NameError:
    def execfile(filename, globs):
        """A Python 3 implementation of execfile."""
        exec(compile(open(filename).read(), filename, 'exec'), globs)
<commit_msg>Use ‘os.path.join’ to join filesystem path components.<commit_after>"""Add things to old Pythons so I can pretend they are newer, for tests."""

# pylint: disable-msg=W0622
# (Redefining built-in blah)
# The whole point of this file is to redefine built-ins, so shut up about it.

import os, sys

# Py2k and 3k don't agree on how to run commands in a subprocess.
try:
    import subprocess
except ImportError:
    def run_command(cmd):
        """Run a command in a subprocess.

        Returns the exit code and the combined stdout and stderr.

        """
        _, stdouterr = os.popen4(cmd)
        return 0, stdouterr.read()
else:
    def run_command(cmd):
        """Run a command in a subprocess.

        Returns the exit code and the combined stdout and stderr.

        """

        if sys.hexversion > 0x03000000 and cmd.startswith("coverage "):
            # We don't have a coverage command on 3.x, so fix it up to call the
            # script. Eventually we won't need this.
            script_path = os.path.join(sys.prefix, "Scripts", cmd)
            cmd = "python " + script_path

        proc = subprocess.Popen(cmd, shell=True,
                stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT
                )
        retcode = proc.wait()

        # Get the output, and canonicalize it to strings with newlines.
        output = proc.stdout.read()
        if not isinstance(output, str):
            output = output.decode('utf-8')
        output = output.replace('\r', '')

        return retcode, output

# No more execfile in Py3k
try:
    execfile = execfile
except NameError:
    def execfile(filename, globs):
        """A Python 3 implementation of execfile."""
        exec(compile(open(filename).read(), filename, 'exec'), globs)

{'fraction_non_alphanumeric': 0.09685641461342395, 'fraction_numerical': 0.0118946474086661, 'mean_word_length': 2.3415326395458846, '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': '2175940', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1011, 'n_words': 374}