<commit_before>import subprocess

from functools import wraps
from os.path import splitext, join

extensions = {}


def extension(f):
    # keep unwrapped function
    unwrapped = f

    @wraps(f)
    def wrapper(**kwargs):
        wrapper.settings = dict(kwargs)
        return unwrapped
    extensions[f.__name__] = wrapper
    return wrapper


@extension
def coffee(filename, data):
    command = ['coffee', '-c', '-s']
    bare = coffee.settings.get('bare')
    if bare:
        command.append('-b')

    process = subprocess.Popen(command, stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = process.communicate(data)

    if process.returncode:
        return None, err
    else:
        _,ext = splitext(filename)
        dest = filename.replace(ext, '.js')
        return dest, out

@extension
def dest(filename, data):
    destination = dest.settings.get('destination')
    if destination:
        filename = join(destination, filename)

    fo = open(filename, 'w')
    fo.write(data)
    fo.close()
<commit_msg>Import os instead of some functions<commit_after>import subprocess

from functools import wraps
import os

extensions = {}


def extension(f):
    # keep unwrapped function
    unwrapped = f

    @wraps(f)
    def wrapper(**kwargs):
        wrapper.settings = dict(kwargs)
        return unwrapped
    extensions[f.__name__] = wrapper
    return wrapper


@extension
def coffee(filename, data):
    command = ['coffee', '-c', '-s']
    bare = coffee.settings.get('bare')
    if bare:
        command.append('-b')

    process = subprocess.Popen(command, stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = process.communicate(data)

    if process.returncode:
        return None, err
    else:
        _, ext = os.path.splitext(filename)
        dest = filename.replace(ext, '.js')
        return dest, out

@extension
def dest(filename, data):
    destination = dest.settings.get('destination')
    if destination:
        filename = os.path.join(destination, tail)

    fo = open(filename, 'w')
    fo.write(data)
    fo.close()

{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.0, 'mean_word_length': 2.659966499162479, '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': '3458692', 'n_tokens_mistral': 672, 'n_tokens_neox': 647, 'n_words': 164}