annotate makeitso/mkpydir.py @ 227:8ee4ff7a89c7

one more time
author Jeff Hammel <k0scist@gmail.com>
date Mon, 14 Dec 2015 14:07:06 -0800
parents 7d8f3660fabb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 make a python module directory with an __init__.py
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 """
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6
189
7d8f3660fabb fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents: 167
diff changeset
7 import argparse
167
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 import os
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 import sys
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 def main(args=sys.argv[1:]):
189
7d8f3660fabb fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents: 167
diff changeset
12 """CLI"""
167
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13
189
7d8f3660fabb fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents: 167
diff changeset
14 parser = argparse.ArgumentParser(description=__doc__)
7d8f3660fabb fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents: 167
diff changeset
15 parser.add_argument('directory')
7d8f3660fabb fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents: 167
diff changeset
16 options = parser.parse_args(args)
167
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17
189
7d8f3660fabb fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents: 167
diff changeset
18 os.makedirs(options.directory)
7d8f3660fabb fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents: 167
diff changeset
19 init = os.path.join(options.directory, '__init__.py')
7d8f3660fabb fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents: 167
diff changeset
20 with open(init, 'w') as f:
167
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 f.write('#\n')
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 if __name__ == '__main__':
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 main()