Created
May 11, 2017 13:06
-
-
Save specialunderwear/d029bdc9dd0b35b3d0b5fbb2857b1b78 to your computer and use it in GitHub Desktop.
Initialize a package directory structure with __init__.py files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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