Mercurial > hg > MakeItSo
annotate makeitso/python_package/{{package}}/{{main}}.py @ 187:74f41d53b057
STUB: makeitso/python_package/{{package}}/{{main}}.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 11 Apr 2014 17:06:22 -0700 |
parents | a5d058957734 |
children | 1bcf60bcc455 |
rev | line source |
---|---|
79 | 1 #!/usr/bin/env python |
159 | 2 # -*- coding: utf-8 -*- |
79 | 3 |
4 """ | |
5 {{description}} | |
6 """ | |
7 | |
187
74f41d53b057
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
161
diff
changeset
|
8 # imports |
159 | 9 import optparse |
10 import os | |
11 import subprocess | |
79 | 12 import sys |
159 | 13 |
187
74f41d53b057
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
161
diff
changeset
|
14 __all__ = ['main'] |
74f41d53b057
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
161
diff
changeset
|
15 here = os.path.dirname(os.path.realpath(__file__)) |
74f41d53b057
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
161
diff
changeset
|
16 |
159 | 17 def add_options(parser): |
161 | 18 """add options to the OptionParser instance""" |
79 | 19 |
155
386a44a52139
moving to a thing with script template
Jeff Hammel <jhammel@mozilla.com>
parents:
149
diff
changeset
|
20 def main(args=sys.argv[1:]): |
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
21 |
139 | 22 # parse command line options |
159 | 23 usage = '%prog [options] ...' |
139 | 24 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): |
140 | 25 """description formatter for console script entry point""" |
139 | 26 def format_description(self, description): |
27 if description: | |
149 | 28 return description.strip() + '\n' |
139 | 29 else: |
30 return '' | |
31 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) | |
32 options, args = parser.parse_args(args) | |
79 | 33 |
34 if __name__ == '__main__': | |
139 | 35 main() |