annotate makeitso/mkpydir.py @ 182:215a71ac0eff

TODO
author Jeff Hammel <k0scist@gmail.com>
date Sun, 23 Mar 2014 11:53:11 -0700
parents f6474c7dfb39
children 7d8f3660fabb
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
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 import optparse
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:]):
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 usage = '%prog [options] directory_name'
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 parser = optparse.OptionParser(usage=usage, description=__doc__)
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 options, args = parser.parse_args(args)
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 if len(args) != 1:
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 parser.print_usage()
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 parser.error()
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 os.makedirs(args[0])
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 init = os.path.join(args[0], '__init__.py')
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 with f as open(init, 'w'):
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 f.write('#\n')
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 if __name__ == '__main__':
f6474c7dfb39 makeitso/mkpydir.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 main()