def genPyApp(self, conf, module): wendergen = ServerWenderGen() gen = PyGen() formatter = PyFormatter() # wendergen.generate(conf.access, module) # wendergen.flushUrls(self.staticUrls) gen.generate(module) return formatter.generate( self.confsite.build_path, os.path.basename(self.confsite.build_path), module )
def buildStaticApps(self): # compiler = Compiler() # for conf in self.confappstatic: # module = compiler.compile(':'.join(self.confsite.paths), conf.name) # self.genPyApp(conf, module) pyformatter = PyFormatter() for conf in self.confappstatic: staticPath = os.path.join(self.confsite.build_path, os.path.basename(self.projectPath)) initFile = os.path.join(staticPath, '__init__.py') if not os.path.exists(staticPath): os.mkdir(staticPath) with open(initFile, 'w') as f: f.close # copy application files # appSrc = os.path.join(self.projectPath, '%s/%s.py' % (conf.name, conf.name)) # appDest = os.path.join(staticPath, conf.name + '.py') # shutil.copy(appSrc, appDest) pySrc = os.path.join(self.projectPath, '%s/*.py' % conf.name) for filename in glob.glob(pySrc): shutil.copy(filename, staticPath) # copy templates templateDest = os.path.join(self.confsite.build_path, 'templates/%s/' % conf.name) if not os.path.exists(templateDest): os.mkdir(templateDest) # templateSrc = os.path.join(self.projectPath, '%s/templates/*.html' % conf.name) templateSrc = os.path.join(self.projectPath, '%s/templates/*' % conf.name) for filename in glob.glob(templateSrc): shutil.copy(filename, templateDest) # add structs.py vaStructs = core.VariableNode([common.Token(0, 'var', 'var')], 'structs') vaStructs.body = self.structs pyformatter.savePyCode( pyformatter.genVariable(vaStructs), os.path.join(self.confsite.build_path, 'wender/structs.py') )