Skip to content

Instantly share code, notes, and snippets.

@specialunderwear
Created May 11, 2017 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save specialunderwear/d029bdc9dd0b35b3d0b5fbb2857b1b78 to your computer and use it in GitHub Desktop.
Save specialunderwear/d029bdc9dd0b35b3d0b5fbb2857b1b78 to your computer and use it in GitHub Desktop.
Initialize a package directory structure with __init__.py files.
#! /usr/bin/env python
import os
import argparse
def visit(arg, dirname, names):
name = os.path.join(arg, dirname, '__init__.py')
if not os.path.exists(name):
open(name, 'a').close()
def main():
parser = argparse.ArgumentParser(description='Initialize a folder structure to become python packages')
parser.add_argument('path', help='The path to the folder to initialize')
args = parser.parse_args()
os.path.walk(os.path.realpath(args.path), visit, 'koe')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment