<commit_before>#!/usr/bin/env python
from __future__ import print_function
import os
from jinja2 import Template

SOURCE = "src"
DEST = "_src"


def read_file(file_name):
    "Read a file"
    with open(file_name) as f:
        return f.read()


def write_file(file_name, content):
    "Write a file"
    with open(file_name, "w") as f:
        f.write(content)


def navigate(path=[], context={}):
    "Explore file tree expanding each file"

    source = os.path.join(* [SOURCE] + path)
    dest = os.path.join(* [DEST] + path)

    if os.path.isdir(source):
        if not os.path.exists(dest):
            os.makedirs(dest)

        for f in os.listdir(source):
            navigate(path + [f], context)
    else:
        in_code = read_file(source)
        out_code = Template(in_code).render(context)
        write_file(dest, out_code)


def get_modules():
    "Get name of DSL modules"
    path = os.path.join(SOURCE, "dsl")
    files = [f for f in os.listdir(path) if f.endswith(".h")]

    modules = []
    for f in files:
        name = os.path.splitext(f)[0]
        modules.append(name)

    return modules<commit_msg>Avoid mutable default arguments<commit_after>#!/usr/bin/env python
from __future__ import print_function
import os
from jinja2 import Template

SOURCE = "src"
DEST = "_src"


def read_file(file_name):
    "Read a file"
    with open(file_name) as f:
        return f.read()


def write_file(file_name, content):
    "Write a file"
    with open(file_name, "w") as f:
        f.write(content)


def navigate(path=None, context=None):
    "Explore file tree expanding each file"
    if not path:
        path = []
    if not context:
        context = {}

    source = os.path.join(* [SOURCE] + path)
    dest = os.path.join(* [DEST] + path)

    if os.path.isdir(source):
        if not os.path.exists(dest):
            os.makedirs(dest)

        for f in os.listdir(source):
            navigate(path + [f], context)
    else:
        in_code = read_file(source)
        out_code = Template(in_code).render(context)
        write_file(dest, out_code)


def get_modules():
    "Get name of DSL modules"
    path = os.path.join(SOURCE, "dsl")
    files = [f for f in os.listdir(path) if f.endswith(".h")]

    modules = []
    for f in files:
        name = os.path.splitext(f)[0]
        modules.append(name)

    return modules
{'fraction_non_alphanumeric': 0.12468193384223919, 'fraction_numerical': 0.0016963528413910093, 'mean_word_length': 2.5634441087613293, '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': '3990788', 'n_tokens_mistral': 821, 'n_tokens_neox': 794, 'n_words': 218}