<commit_before># -*- coding: utf-8 -*-

__author__ = """<NAME> (<EMAIL>)"""


import os
import sys
from glob import glob

sys.path.append(os.getcwd())

"""Automatically adds all __init__.py files to all subdirectories
that do not already have it."""


def write_init(newpath):
    with open(newpath, 'wb+') as initfile:
        initfile.write('\n')


def modulify():
    paths = []
    start_dir = os.getcwd()
    pattern = "*.py"
    for dir, subdirs, files in os.walk(start_dir):
        if '.git' not in dir:
            if '__init__.py' not in files or len(dir) == 0:
                newpath = '{}/__init__.py'.format(dir)
                write_init(newpath)
        paths.extend(glob(os.path.join(dir, pattern)))
    return paths


modulify()<commit_msg>Clean up modulify code.<commit_after># -*- coding: utf-8 -*-

"""Automatically adds all __init__.py files to all subdirectories
that do not already have it."""

__author__ = """<NAME> (<EMAIL>)"""

import os
import sys
from glob import glob

sys.path.append(os.getcwd())


def write_init(newpath):
    """Write an empty __init__ file to a path."""
    with open(newpath, 'wb+') as initfile:
        initfile.write('\n')


def modulify():
    """Make __init__ files in all directories and subdirectories."""
    paths = []
    start_dir = os.getcwd()
    pattern = "*.py"
    for dir, subdirs, files in os.walk(start_dir):
        if '.git' not in dir:
            if '__init__.py' not in files or len(dir) == 0:
                newpath = '{}/__init__.py'.format(dir)
                write_init(newpath)
        paths.extend(glob(os.path.join(dir, pattern)))
    return paths


if __name__ == '__main__':
    modulify()
{'fraction_non_alphanumeric': 0.14669051878354203, 'fraction_numerical': 0.002385211687537269, 'mean_word_length': 2.7455357142857144, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5278952', 'n_tokens_mistral': 566, 'n_tokens_neox': 550, 'n_words': 163}