示例#1
0
    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
示例#2
0
    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
示例#3
0
文件: util.py 项目: nbastin/loxigen
def render_template(out, name, **context):
    utils.render_template(out, name, [templates_dir], context)
示例#4
0
文件: util.py 项目: capveg/loxigen
def render_template(out, name, **context):
    utils.render_template(out, name, template_path, context)
示例#5
0
def render_template(out, name, **context):
    utils.render_template(out, name, template_path, context)
示例#6
0
def generate(out, name):
    context = {
        'fields': create_fields(),
    }
    utils.render_template(out, "openflow.lua", [templates_dir], context)
示例#7
0
def render_template(out, name, **context):
    utils.render_template(out, name, [templates_dir], context)
示例#8
0
def generate(out, name):
    context = {
        'fields': create_fields(),
    }
    utils.render_template(out, "openflow.lua", [templates_dir], context)
示例#9
0
文件: msgs.py 项目: capveg/loxigen
def render_template(out, name, **context):
    prefix = '//::(?=[ \t]|$)'
    utils.render_template(out, name, [templates_dir], context, prefix=prefix)