moa.template

moa.template

Store information on a template. This module is also responsible for retrieving template information.

moa.template.initTemplate(*args, **kwargs)
moa.template.installTemplate(wd, tName, provider=None)

Initialize the template - this means - try to figure out where the template came from & copy the template files into job/.moa/template & job/.moa/template.d/extra.

Currently all templates come from the moa repository. In the future, multiple sources must be possible

>>> import tempfile
>>> wd = tempfile.mkdtemp()
>>> installTemplate(wd, 'simple')
>>> templateFile = os.path.join(wd, '.moa', 'template')
>>> adhocFile = os.path.join(wd, '.moa', 'template.d', 'simple.jinja2')
>>> assert(os.path.exists(templateFile))
>>> assert(os.path.exists(adhocFile))
moa.template.refresh(wd)

Refresh the template - try to find out what the template is from {{wd}}/.moa/template.meta. If that doesn’t work, revert to the default template. If default is not specified - exit with an error

>>> import tempfile
>>> wd = tempfile.mkdtemp()
>>> installTemplate(wd, 'simple')
>>> templateFile = os.path.join(wd, '.moa', 'template')
>>> adhocFile = os.path.join(wd, '.moa', 'template.d', 'simple.jinja2')
>>> os.unlink(adhocFile)
>>> os.unlink(templateFile)
>>> assert(not os.path.exists(templateFile))
>>> assert(not os.path.exists(adhocFile))
>>> refresh(wd)
>>> assert(os.path.exists(templateFile))
>>> assert(os.path.exists(adhocFile))

moa.template.template

Store information on a template. This module is also responsible for retrieving template information.

class moa.template.template.Template(wd)

Template extends Yaco

getRaw()

Return a Yaco representation of the yaml-template, without any of this Template processing. This is really useful when processing a template that needs to be written back to disk

>>> import moa.job
>>> job = moa.job.newTestJob(template='simple')
>>> raw = job.template.getRaw()
>>> assert(isinstance(raw, Yaco.Yaco))
>>> assert(raw.has_key('parameters'))
loadMeta()

Load the template meta data for this job, based on what configuration can be found