Beispiel #1
0
def _compile_dir(root_path, app, view_dir='view'):
    print 'compile views in "%s" for app "%s"...' % (view_dir, app)
    all_views = os.listdir(os.path.join(root_path, app, view_dir))
    views = [
        v for v in all_views
        if os.path.isfile(os.path.join(root_path, app, view_dir, v))
    ]
    count = 0
    for v in views:
        if v.endswith('.html'):
            print '  compile "%s"...' % v
            mod_name = v[:-5]
            content = view.compile_template(app, mod_name, view_dir=view_dir)
            content_dir = os.path.join(root_path, 'compiled', app, view_dir)
            _mkdirs(content_dir)
            _gen_init_py(content_dir)
            file = os.path.join(content_dir, '%s.py' % mod_name)
            f = open(file, 'w')
            f.write(content)
            f.close()
            count += 1
    app_dir = os.path.join(root_path, 'compiled', app)
    _mkdirs(app_dir)
    _gen_init_py(app_dir)
    print '%d view(s) compiled.' % count
    return count
Beispiel #2
0
def _compile_dir(root_path, app, view_dir='view'):
    print 'compile views in "%s" for app "%s"...' % (view_dir, app)
    all_views = os.listdir(os.path.join(root_path, app, view_dir))
    views = [v for v in all_views if os.path.isfile(os.path.join(root_path, app, view_dir, v))]
    count = 0
    for v in views:
        if v.endswith('.html'):
            print '  compile "%s"...' % v
            mod_name = v[:-5]
            content = view.compile_template(app, mod_name, view_dir=view_dir)
            content_dir = os.path.join(root_path, 'compiled', app, view_dir)
            _mkdirs(content_dir)
            _gen_init_py(content_dir)
            file = os.path.join(content_dir, '%s.py' % mod_name)
            f = open(file, 'w')
            f.write(content)
            f.close()
            count += 1
    app_dir = os.path.join(root_path, 'compiled', app)
    _mkdirs(app_dir)
    _gen_init_py(app_dir)
    print '%d view(s) compiled.' % count
    return count
Beispiel #3
0
 def test_compile_template2(self):
     cls = view.compile_template('http_test',
                                 'custom',
                                 view_dir='custom_view')
     self.assertTrue(isinstance(cls, str))
     self.assertTrue(cls.find('CompiledTemplate') >= 0)
Beispiel #4
0
 def test_compile_template(self):
     cls = view.compile_template('http_test', 'main')
     self.assertTrue(isinstance(cls, str))
     self.assertTrue(cls.find('CompiledTemplate') >= 0)
Beispiel #5
0
 def test_compile_template2(self):
     cls = view.compile_template('http_test', 'custom', view_dir='custom_view')
     self.assertTrue(isinstance(cls, str))
     self.assertTrue(cls.find('CompiledTemplate')>=0)
Beispiel #6
0
 def test_compile_template(self):
     cls = view.compile_template('http_test', 'main')
     self.assertTrue(isinstance(cls, str))
     self.assertTrue(cls.find('CompiledTemplate')>=0)