Mercurial > hg > MakeItSo
diff makeitso/cli.py @ 98:37f92ae8f999
separate out variable getting to its own function
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 11 Jan 2011 11:35:38 -0800 |
parents | e74baa8e6df4 |
children | 9c70669854f4 |
line wrap: on
line diff
--- a/makeitso/cli.py Tue Jan 11 10:51:22 2011 -0800 +++ b/makeitso/cli.py Tue Jan 11 11:35:38 2011 -0800 @@ -15,7 +15,7 @@ """ return a command line parser for the template """ - usage = '%prog [options] output' + usage = getattr(self, 'usage', '%prog [options] output') description = getattr(self.template_class, 'description', None) parser = OptionParser(usage=usage, description=description) @@ -29,6 +29,14 @@ help=description) return parser + def get_variables(self, options): + """ + return variables from (parsed) options + """ + return dict([(key, value) + for key, value in options.__dict__.items() + if not key.startswith('_')]) + def parse(self, args=None, parser=None, options=None): # parse the command line @@ -41,11 +49,9 @@ parser.error("Please specify a single output destination") # template variables - variables = dict([(key, value) - for key, value in options.__dict__.items() - if not key.startswith('_')]) - - # + variables = self.get_variables(options) + + # return the variables and the output return variables, args[0] def __call__(self, *args):