Mercurial > hg > MakeItSo
comparison makeitso/cli.py @ 174:aed8c4af5f26
STUB: makeitso/cli.py makeitso/script2package.py setup.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Thu, 16 Jan 2014 13:31:54 -0800 |
parents | b2152efec89a |
children |
comparison
equal
deleted
inserted
replaced
173:ceb8c8042e48 | 174:aed8c4af5f26 |
---|---|
5 from template import Undefined | 5 from template import Undefined |
6 from optparse import OptionParser | 6 from optparse import OptionParser |
7 | 7 |
8 class MakeItSoCLI(object): | 8 class MakeItSoCLI(object): |
9 """command line interface to a makeitso template""" | 9 """command line interface to a makeitso template""" |
10 | 10 |
11 def __init__(self, template_class): | 11 def __init__(self, template_class): |
12 self.template_class = template_class | 12 self.template_class = template_class |
13 | 13 |
14 def parser(self): | 14 def parser(self): |
15 """ | 15 """ |
48 if len(args) != 1: | 48 if len(args) != 1: |
49 parser.error("Please specify a single output destination") | 49 parser.error("Please specify a single output destination") |
50 | 50 |
51 # template variables | 51 # template variables |
52 variables = self.get_variables(options) | 52 variables = self.get_variables(options) |
53 | 53 |
54 # return the variables and the output | 54 # return the variables and the output |
55 return variables, args[0] | 55 return variables, args[0] |
56 | 56 |
57 def __call__(self, *args): | 57 def __call__(self, *args): |
58 """interpolate template""" | |
58 variables, output = self.parse(list(args)) | 59 variables, output = self.parse(list(args)) |
59 template = self.template_class(variables=variables) | 60 template = self.template_class(variables=variables) |
60 template.substitute({}, output=output) | 61 template.substitute({}, output=output) |