comparison makeitso/python_module/{{module}}.py @ 130:d9201f911458

better description formatting
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 01 Aug 2011 21:58:15 -0700
parents 57834c2b0937
children a203f79c537f
comparison
equal deleted inserted replaced
129:57834c2b0937 130:d9201f911458
3 """ 3 """
4 {{module}} 4 {{module}}
5 """ 5 """
6 6
7 import sys 7 import sys
8 from optparse import OptionParser 8 import optparse
9 9
10 def main(args=sys.argv[1:]): 10 def main(args=sys.argv[1:]):
11 11
12 # parse command line arguments 12 # parse command line arguments
13 usage = '%prog [options] ...' 13 usage = '%prog [options] ...'
14 parser = OptionParser(usage=usage, description=__doc__) 14
15 # description formatter
16 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
17 def format_description(self, description):
18 if description:
19 return description + '\n'
20 else:
21 return ''
22
23 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
15 options, args = parser.parse_args(args) 24 options, args = parser.parse_args(args)
16 25
17 if __name__ == '__main__': 26 if __name__ == '__main__':
18 main() 27 main()