def createOutputFile(self, ext, contents=""): """create an output file, filling it with contents.""" fpath = self.getOutputFile(ext) fileOps.ensureFileDir(fpath) fh = open(fpath, "w") try: fh.write(contents) finally: fh.close()
def _touch(self, fp): "create a file product" self.tester.failUnless(isinstance(fp, File)) ext = os.path.splitext(fp.path)[1] fileOps.ensureFileDir(fp.getOutPath()) fh = open(fp.getOutPath(), "w") try: fh.write(self.pset.contents.get(fp)) finally: fh.close() self.touchCnt += 1
def getOutPath(self, autoCompress=True): """Get the output name for the file, which is newPath until the rule terminates. This will also create the output directory for the file, if it does not exist. One wants to use FileOut() to define a command argument. This should not be used to get the path to a file to be opened in the ExRun process, use openOut() instead.""" if self.installed: raise ExRunException("output file already installed: " + self.path) if self.outPath == None: fileOps.ensureFileDir(self.path) self.outPath = self.exrun.getAtomicPath(self.path) return self.outPath
def getOutputFile(self, ext): """Get path to the output file, using the current test id and append ext, which should contain a dot""" f = self.getOutputDir() + "/" + self.getId() + ext fileOps.ensureFileDir(f) return f
def execute(self): "create file product" for fp in self.produces: fileOps.ensureFileDir(fp.path) open(fp.path, "w").close()
def getOutputFile(self, ext): """Get path to the output file, using the current test id and append ext, which should contain a dot""" f = self.getOutputDir() + "/" + self.getId() + ext; fileOps.ensureFileDir(f) return f