Mercurial > hg > MakeItSo
changeset 42:73dac34d2692
more stubbing of API class; first get something off the ground; then rewrite
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 04 Jan 2011 07:38:49 -0800 |
parents | 9956e13558dd |
children | 554f916cef13 |
files | makeitso/makeitso.py makeitso/template.py |
diffstat | 2 files changed, 37 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/makeitso/makeitso.py Mon Jan 03 14:18:59 2011 -0800 +++ b/makeitso/makeitso.py Tue Jan 04 07:38:49 2011 -0800 @@ -283,9 +283,7 @@ class PolyTemplate(ContentTemplate): - """ - template for several files/directories - """ + """template for several files/directories""" def __init__(self, templates, output=None, interactive=True, **variables):
--- a/makeitso/template.py Mon Jan 03 14:18:59 2011 -0800 +++ b/makeitso/template.py Tue Jan 04 07:38:49 2011 -0800 @@ -2,8 +2,10 @@ basic API template class """ +import os import sys from makeitso import ContentTemplate +from makeitso import PolyTemplate class Variable(object): """variable object for MakeItSo templates""" @@ -38,7 +40,38 @@ else: return 'Enter %s:' % description -class MakeItSoTemplate(object): +class MakeItSoTemplate(ContentTemplate): + """API template for MakeItSo""" + + # name of the template + name = '' + + # templates to interpolate + # paths are relative to __file__ unless absolute or URIs + templates = [] + + # variables + vars = [] + + # inspect the templates for more variables + look = False + + def __init__(self, output=None, interactive=True, **variables): + assert self.templates + self.output = output + self.interactive = interactive + self.location = os.path.dirnme(os.path.abspath(__file__)) + self.defaults = variables.copy + + # ensure all of these templates exist + for template in self.templates: + if template.startswith('http://') or template.startswith('https://'): + continue + if os.path.isabs(template): + path = template + else: + path = os.path.join(self.location, template) + assert os.path.exists(template) def pre(self, **variables): """do stuff before interpolation""" @@ -47,3 +80,5 @@ """do stuff after interpolation""" +class PasteScriptTemplate(MakeItSoTemplate): + """template for backwards compatability with PasteScript"""