comparison makeitso/python_package/{{package}}/main.py @ 130:d9201f911458

better description formatting
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 01 Aug 2011 21:58:15 -0700
parents 8c326f764cfe
children 23652cbfdfad
comparison
equal deleted inserted replaced
129:57834c2b0937 130:d9201f911458
3 """ 3 """
4 {{description}} 4 {{description}}
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[:]): 10 def main(args=sys.argv[:]):
11
12 # parse command line options
11 usage = '%prog [options]' 13 usage = '%prog [options]'
12 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())
13 options, args = parser.parse_args(args) 24 options, args = parser.parse_args(args)
14 25
15 if __name__ == '__main__': 26 if __name__ == '__main__':
16 main() 27 main()