# -*- coding: utf-8 -*-

__author__ = """Chris Tabor (dxdstudio@gmail.com)"""


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()

@@ -18,16 +18,115 @@
 -8 -*-%0A%0A
+%22%22%22Automatically adds all __init__.py files to all subdirectories%0Athat do not already have it.%22%22%22%0A%0A
 __author
@@ -171,17 +171,16 @@
 om)%22%22%22%0A%0A
-%0A
 import o
@@ -249,33 +249,55 @@
 ))%0A%0A
-%22%22%22Automatically adds all
+%0Adef write_init(newpath):%0A    %22%22%22Write an empty
  __i
@@ -305,98 +305,27 @@
 it__
-.py
  file
-s
  to a
-ll subdirectories%0Athat do not already have it.%22%22%22%0A%0A%0Adef write_init(newpath):
+ path.%22%22%22
 %0A   
@@ -411,16 +411,85 @@
 lify():%0A
+    %22%22%22Make __init__ files in all directories and subdirectories.%22%22%22%0A
     path
@@ -850,16 +850,47 @@
 paths%0A%0A%0A
+if __name__ == '__main__':%0A    
 modulify

Clean up modulify code.