comparison makeitso/python_module/{{module}}.py @ 154:ebc5cfe17d95

order imports and add an add_options() API
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 01 Dec 2012 19:35:46 -0800
parents a5ea79f3221f
children
comparison
equal deleted inserted replaced
153:a5ea79f3221f 154:ebc5cfe17d95
3 """ 3 """
4 {{module}} 4 {{module}}
5 {{description}} 5 {{description}}
6 """ 6 """
7 7
8 import optparse
8 import sys 9 import sys
9 import optparse 10
11 def add_options(parser):
12 """add {{module}} options to an OptionParser instance"""
13
10 14
11 def main(args=sys.argv[1:]): 15 def main(args=sys.argv[1:]):
12 16
13 # parse command line arguments 17 # parse command line arguments
14 usage = '%prog [options] ...' 18 usage = '%prog [options] ...'
18 if description: 22 if description:
19 return description.strip() + '\n' 23 return description.strip() + '\n'
20 else: 24 else:
21 return '' 25 return ''
22 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) 26 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
27 add_options(parser)
23 options, args = parser.parse_args(args) 28 options, args = parser.parse_args(args)
24 29
25 if __name__ == '__main__': 30 if __name__ == '__main__':
26 main() 31 main()