# HG changeset patch # User Jeff Hammel # Date 1294774538 28800 # Node ID 37f92ae8f999dcec2180083a40f06bde36760a14 # Parent 3eb34cad58581158ace032240739d88db46c1b81 separate out variable getting to its own function diff -r 3eb34cad5858 -r 37f92ae8f999 makeitso/cli.py --- 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):