def _render_action(self, resource, action): log.debug('Rendering %s %s', resource.name, action) action_file = resource.actions[action] log.debug('action file: %s', action_file) args = self._make_args(resource) return utils.render_template(action_file, str=str, zip=zip, **args)
def profile(id, tags, create): if not id: id = utils.generate_uuid() if create: params = {'tags': tags, 'id': id} profile_template_path = os.path.join( utils.read_config()['template-dir'], 'profile.yml') data = yaml.load(utils.render_template(profile_template_path, params)) db.store('profiles', data) else: pprint.pprint(db.get_list('profiles'))
def _render_action(self, resource, action): log.debug('Rendering %s %s', resource.name, action) action_file = resource.actions[action] log.debug('action file: %s', action_file) args = self._make_args(resource) return utils.render_template( action_file, str=str, zip=zip, **args)
def _render_dir(self, resource, _path): args = self._make_args(resource) for f in os.listdir(_path): if f.endswith('.jinja'): target_f = f[:-6] full_target = os.path.join(_path, target_f) full_src = os.path.join(_path, f) with open(full_target, 'wb') as tmpl_f: tpl = utils.render_template(full_src, str=str, zip=zip, **args) tmpl_f.write(tpl) log.debug("Rendered: %s", full_target) os.remove(full_src)
def _render_dir(self, resource, _path): args = self._make_args(resource) for f in os.listdir(_path): if f.endswith('.jinja'): target_f = f[:-6] full_target = os.path.join(_path, target_f) full_src = os.path.join(_path, f) with open(full_target, 'wb') as tmpl_f: tpl = utils.render_template( full_src, str=str, zip=zip, **args) tmpl_f.write(tpl) log.debug("Rendered: %s", full_target) os.remove(full_src)