comparison mozillatry.py @ 1:0f8e4a3b4e1c

split add_options to its own method for consumption
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 01 Dec 2012 19:42:38 -0800
parents df6a8049e9a4
children 3eaee0d10880
comparison
equal deleted inserted replaced
0:df6a8049e9a4 1:0f8e4a3b4e1c
72 message += ['-t', (','.join(talos) if talos else 'none')] 72 message += ['-t', (','.join(talos) if talos else 'none')]
73 if bug: 73 if bug:
74 message += ['--post-to-bugzilla', str(bug)] 74 message += ['--post-to-bugzilla', str(bug)]
75 return ' '.join(message) 75 return ' '.join(message)
76 76
77 def main(args=sys.argv[1:]): 77 def add_options(parser):
78 """add options for mozilla try to an OptionParser instance"""
78 79
79 # parse command line arguments
80 usage = '%prog [options] patch <patch2> <...>'
81 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
82 """description formatter"""
83 def format_description(self, description):
84 description = description.strip()
85 if description:
86 return description + '\n'
87 else:
88 return ''
89 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
90 parser.add_option('--no-opt', dest='opt', 80 parser.add_option('--no-opt', dest='opt',
91 action='store_false', default=True, 81 action='store_false', default=True,
92 help='no opt builds') 82 help='no opt builds')
93 parser.add_option('--no-debug', dest='debug', 83 parser.add_option('--no-debug', dest='debug',
94 action='store_false', default=True, 84 action='store_false', default=True,
100 parser.add_option('--bug', dest='bug', type='int', 90 parser.add_option('--bug', dest='bug', type='int',
101 help='post to bugzilla bug #') 91 help='post to bugzilla bug #')
102 parser.add_option('-c', '--config', dest='config', 92 parser.add_option('-c', '--config', dest='config',
103 default=os.path.join(os.environ['HOME'], '.mozutils.ini'), 93 default=os.path.join(os.environ['HOME'], '.mozutils.ini'),
104 help='location of config file') 94 help='location of config file')
95
96
97 def main(args=sys.argv[1:]):
98
99 # parse command line arguments
100 usage = '%prog [options] patch <patch2> <...>'
101 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
102 """description formatter"""
103 def format_description(self, description):
104 description = description.strip()
105 if description:
106 return description + '\n'
107 else:
108 return ''
109 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
110 add_options(parser)
105 options, args = parser.parse_args(args) 111 options, args = parser.parse_args(args)
106 if not args: 112 if not args:
107 parser.print_help() 113 parser.print_help()
108 parser.exit() 114 parser.exit()
109 if (not options.opt) and (not options.debug): 115 if (not options.opt) and (not options.debug):