Mercurial > hg > MakeItSo
annotate makeitso/python_package/{{package}}/main.py @ 138:169e02e190ef
peg to tempita version and eliminate cruft
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 21 Feb 2012 21:01:28 -0800 |
parents | d9201f911458 |
children | 23652cbfdfad |
rev | line source |
---|---|
79 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 {{description}} | |
5 """ | |
6 | |
7 import sys | |
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
8 import optparse |
79 | 9 |
10 def main(args=sys.argv[:]): | |
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
11 |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
12 # parse command line options |
79 | 13 usage = '%prog [options]' |
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
14 |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
15 # description formatter |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
16 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
17 def format_description(self, description): |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
18 if description: |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
19 return description + '\n' |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
20 else: |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
21 return '' |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
22 |
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
23 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) |
79 | 24 options, args = parser.parse_args(args) |
25 | |
26 if __name__ == '__main__': | |
27 main() |