def processConfigFile(self): # config file self.spyce_config = {} if not self.file: self.file = self.findConfigFile() if self.file: if not os.path.exists(self.file): raise spyceException.spyceNotFound(self.file) if not os.access(self.file, os.R_OK): raise spyceException.spyceForbidden(self.file) self.spyce_config = self.parseConfigFile()
def cheetahGenerate(filename): # check permissions if not os.path.exists(filename): raise spyceException.spyceNotFound() if not os.access(filename, os.R_OK): raise spyceException.spyceForbidden() # read the template f = None try: f = open(filename, 'r') buf = f.read() finally: if f: f.close() # compile template, get timestamp mtime = os.path.getmtime(filename) from Cheetah.Compiler import Compiler code = Compiler(source=buf).__str__() dict = {} exec code in dict return mtime, dict['GenTemplate']
def spyceFileCacheGenerate(key): "Generate new Spyce wrapper (recompiles)." try: filename, sig = key except: filename, sig = key, '' # ensure file exists and we have permissions if not os.path.exists(filename): raise spyceException.spyceNotFound(filename) if not os.access(filename, os.R_OK): raise spyceException.spyceForbidden(filename) # generate mtime = os.path.getmtime(filename) f = None try: f = open(filename) code = f.read() finally: if f: f.close() s = spyceCode(code, filename=filename, sig=sig) return mtime, s
def cheetahGenerate(filename): # check permissions if not os.path.exists(filename): raise spyceException.spyceNotFound() if not os.access(filename, os.R_OK): raise spyceException.spyceForbidden() # read the template f = None try: f = open(filename, "r") buf = f.read() finally: if f: f.close() # compile template, get timestamp mtime = os.path.getmtime(filename) from Cheetah.Compiler import Compiler code = Compiler(source=buf).__str__() dict = {} exec code in dict return mtime, dict["GenTemplate"]