# HG changeset patch # User Jeff Hammel # Date 1354648185 28800 # Node ID 416f4562005c8fcd1a9e32efc5515a827a9b3e32 # Parent 14275dcbff10f98f60b57dc66017bd6afc9d44fe more switching to configuration parser diff -r 14275dcbff10 -r 416f4562005c mozillatry.py --- a/mozillatry.py Tue Dec 04 09:51:34 2012 -0800 +++ b/mozillatry.py Tue Dec 04 11:09:45 2012 -0800 @@ -67,6 +67,8 @@ return ' '.join(message) class MozillaTryConfiguration(configuration.Configuration): + + usage = '%prog [options] patch <...>' options = {'opt': {'default': True, 'help': "whether to try on opt builds"}, 'debug': {'default': True, @@ -82,6 +84,19 @@ 'flags': ["--m-c", "--mozilla-central"]} } + def __init__(self): + configuration.Configuration.__init__(usage=self.usage, load='--config') + + def check(self, parser, options, args): + """check configuration""" + + if not args: + parser.print_help() + parser.exit() + if (not options.opt) and (not options.debug): + parser.error("Must enable opt or debug builds") + + def read_config(filename, options): """read .mozutils config file and substitute for options if None""" @@ -101,33 +116,14 @@ pass return parser -def check(parser, options, args): - """check configuration""" - - if not args: - parser.print_help() - parser.exit() - if (not options.opt) and (not options.debug): - parser.error("Must enable opt or debug builds") def main(args=sys.argv[1:]): # parse command line arguments - usage = '%prog [options] patch <...>' - class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): - """description formatter""" - def format_description(self, description): - description = description.strip() - if description: - return description + '\n' - else: - return '' - config_file = options.config - read_config(config_file) + config = MozillaTryConfiguration() # get mozilla-central repository directory - if os.path.exists(config_file): try_directory = options.mozilla_central if (try_directory is None) or (not os.path.exists(try_directory)): parser.error("mozilla-central directory does not exist: %s" % try_directory) diff -r 14275dcbff10 -r 416f4562005c setup.py --- a/setup.py Tue Dec 04 09:51:34 2012 -0800 +++ b/setup.py Tue Dec 04 11:09:45 2012 -0800 @@ -9,7 +9,7 @@ version = '0.0' -deps = [] +deps = ['configuration'] setup(name='mozillatry', version=version,