<commit_before>from subprocess import Popen, PIPE
try:
    import lzma
except ImportError:
    try:
        Popen(["xz", "--version"], stdout=PIPE)
        binary = "xz"
    except OSError:
        raise OSError("Couldn't find neither python-lzma or the xz binary.")

def compress(value):
    """Compresses a string with either python-lzma or the xz binary"""
    if lzma:
        return lzma.compress(value)

    process = Popen([binary, "--compress", "--force"], stdin=PIPE, stdout=PIPE)
    return process.communicate(value)[0]

def decompress(value):
    """Decompresses a string with either python-lzma or the xz binary"""
    if lzma:
        return lzma.decompress(value)

    process = Popen([binary, "--decompress", "--stdout", "--force"],
                    stdin=PIPE, stdout=PIPE)
    return process.communicate(value)[0]<commit_msg>Adds compress_file(path), which compresses path with xz binary<commit_after>from subprocess import Popen, PIPE
try:
    import lzma
except ImportError:
    try:
        Popen(["xz", "--version"], stdout=PIPE)
        binary = "xz"
    except OSError:
        raise OSError("Couldn't find neither python-lzma or the xz binary.")

def compress(value):
    """Compresses a string with either python-lzma or the xz binary"""
    if lzma:
        return lzma.compress(value)

    process = Popen([binary, "--compress", "--force"], stdin=PIPE, stdout=PIPE)
    return process.communicate(value)[0]

def decompress(value):
    """Decompresses a string with either python-lzma or the xz binary"""
    if lzma:
        return lzma.decompress(value)

    process = Popen([binary, "--decompress", "--stdout", "--force"],
                    stdin=PIPE, stdout=PIPE)
    return process.communicate(value)[0]

def compress_file(path):
    """Compress the file at 'path' with the xz binary"""

    binary = "xz"
    process = Popen([binary, "--compress", "--force", "--stdout", path], stdout=PIPE)
    return process.communicate()[0]
{'fraction_non_alphanumeric': 0.13689567430025446, 'fraction_numerical': 0.002544529262086514, 'mean_word_length': 3.191897654584222, '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': '6676098', 'n_tokens_mistral': 636, 'n_tokens_neox': 615, 'n_words': 180}