示例#1
0
 def render(self, dest):
     """
     `dest' is a path (abs or rel) to the output directory, or where to
     write the model files to.
     """
     dest = abspath(dest)
     rsync(self._template_path, dest)
def check_tarball(resdir, tfilter=None, rootmod=None):
    test_res = os.path.join(resources, resdir)
    man = parse_manifest(os.path.join(test_res, "manifest"))
    tarroot = os.path.join(test_res, "root")
    if tfilter is None:
        tfilter = _tar_filter

    with tmpdir() as staging:
        if rootmod is not None:
            newroot = os.path.join(staging, "root")
            rsync(tarroot, newroot)
            tarroot = newroot
            rootmod(tarroot)
        tname = os.path.join(staging, "test.tar.gz")
        tf = tarfile.open(tname, mode="w:gz")
        tf.add(tarroot, arcname=".", filter=tfilter)

        tf.close()
        with open_compressed_tarball(tname) as tar:
            man.check_tarball(tar)
示例#3
0
    def render(self, dest):
        """
        `dest' is a path (abs or rel) to the output directory, or where to
        write the model files to. Be extra-sure to call setContext on this
        particular class, it's important to render out the Jinja context
        correctly.
        """
        dest = abspath(dest)

        if self.context is None:
            raise ValueError("No context set for this JinjaTemplate")

        with tmpdir() as tmp:
            PlainTemplate.render(self, tmp)
            for template in dir_walk(tmp, xtn=".tpl"):
                with open(template, 'r') as fd:
                    tobj = Template(fd.read())
                    with open(template.rsplit(".", 1)[0], 'w') as obj:
                        obj.write(tobj.render(**self.context))
                rm(template)
            rsync(tmp, dest)