Mercurial > hg > MakeItSo
annotate makeitso/mkpydir.py @ 268:64979cfff465 default tip
some py3 fixes
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 29 May 2018 15:28:41 -0700 |
parents | 7d8f3660fabb |
children |
rev | line source |
---|---|
167 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 make a python module directory with an __init__.py | |
5 """ | |
6 | |
189
7d8f3660fabb
fix syntax error and use argparse
Jeff Hammel <k0scist@gmail.com>
parents:
167
diff
changeset
|
7 import argparse |
167 | 8 import os |
9 import sys | |
10 | |
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 | 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 | 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 | 21 f.write('#\n') |
22 | |
23 if __name__ == '__main__': | |
24 main() |