Beispiel #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
Beispiel #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
Beispiel #3
0
def render_template(out, name, **context):
    utils.render_template(out, name, [templates_dir], context)
Beispiel #4
0
def render_template(out, name, **context):
    utils.render_template(out, name, template_path, context)
Beispiel #5
0
def render_template(out, name, **context):
    utils.render_template(out, name, template_path, context)
Beispiel #6
0
def generate(out, name):
    context = {
        'fields': create_fields(),
    }
    utils.render_template(out, "openflow.lua", [templates_dir], context)
Beispiel #7
0
def render_template(out, name, **context):
    utils.render_template(out, name, [templates_dir], context)
Beispiel #8
0
def generate(out, name):
    context = {
        'fields': create_fields(),
    }
    utils.render_template(out, "openflow.lua", [templates_dir], context)
Beispiel #9
0
def render_template(out, name, **context):
    prefix = '//::(?=[ \t]|$)'
    utils.render_template(out, name, [templates_dir], context, prefix=prefix)