def render_class(self, clazz, template, src_dir=None, **context): if not src_dir: src_dir = "src/main/java/" context['class_name'] = clazz.name context['package'] = clazz.package context['template_dir'] = self.templates_dir filename = os.path.join( self.basedir, src_dir, "%s/%s.java" % (clazz.package.replace(".", "/"), clazz.name)) dirname = os.path.dirname(filename) if not os.path.exists(dirname): os.makedirs(dirname) prefix = '//::(?=[ \t]|$)' print "filename: %s" % filename with open(filename, "w") as f: loxi_utils.render_template(f, template, [self.templates_dir], context, prefix=prefix) try: cleaner = ImportCleaner(filename) cleaner.find_used_imports() cleaner.rewrite_file(filename) except: print 'Cannot clean imports from file %s' % filename
def render_class(self, clazz, template, src_dir=None, **context): if not src_dir: src_dir = "src/main/java/" context['class_name'] = clazz.name context['package'] = clazz.package context['template_dir'] = self.templates_dir filename = os.path.join(self.basedir, src_dir, "%s/%s.java" % (clazz.package.replace(".", "/"), clazz.name)) dirname = os.path.dirname(filename) if not os.path.exists(dirname): os.makedirs(dirname) prefix = '//::(?=[ \t]|$)' print "filename: %s" % filename with open(filename, "w") as f: loxi_utils.render_template(f, template, [self.templates_dir], context, prefix=prefix) try: cleaner = ImportCleaner(filename) cleaner.find_used_imports() cleaner.rewrite_file(filename) except: print 'Cannot clean imports from file %s' % filename
def render_template(out, name, **context): utils.render_template(out, name, [templates_dir], context)
def render_template(out, name, **context): utils.render_template(out, name, template_path, context)
def generate(out, name): context = { 'fields': create_fields(), } utils.render_template(out, "openflow.lua", [templates_dir], context)
def render_template(out, name, **context): prefix = '//::(?=[ \t]|$)' utils.render_template(out, name, [templates_dir], context, prefix=prefix)