def writeString(self, outFileName, verbose=False, rejectSave=True, rejectFileName="", rejectLines =[]): """return string representation of file for other's to output. outFileName is used to write rejects if specified or to issue error messages. @return (status, resultString) where if status is True, string will be valid and if false, the input source was apparently empty.""" fname = outFileName writeRejects = (rejectSave and rejectLines != None) if writeRejects: rname = fname + ".rej" if len(rejectFileName) > 0: rname = rejectFileName if self.nsplices < 1: if verbose: print "Nothing new to write to ", fname if self.num < 1: print "Nothing old to copy to ", fname print "Reading ", self.fin, " failed?" return (False, "") if verbose: if writeRejects: print "Writing rejects to ", rname print "Writing to string for ", fname if True: outlist = [] if writeRejects: try: rejfile = fileManager.open(rname,"w") except: err('splicer could not open rejects file for writing: ' + rname) for i in self.sections: isProtected = False for s in self.protectedSymbols: if i == self.getProtectedBlock(s): isProtected = True break if isProtected: continue lines = i.getLines() for p in lines: outlist.append( p.strip("\n") ) stringified = "\n".join(outlist) if writeRejects: date = Line.stringdate() print >> rejfile, "#FROM %s on %s" % (fname, date) for p in rejectLines: print >> rejfile , p.strip("\n") if verbose: if writeRejects: print " Finished ", rname print " Finished ", fname return (True, stringified) else: print "Error writing for "+ fname return (False, "")
if len(rejectLines) == 0: print "No rejection information to put into " + rejectFileName return False if dryrun: print "Dry run: Not writing to " + rejectFileName # For a dry run, don't do anything return True if verbose: print "Writing rejects to: " + rejectFileName outfile = None try: outfile = fileManager.open(rejectFileName,'w') except IOError, e: err('splicer could not open reject file %s for writing: %s' % (rejectFileName, str(e))) if len(originalFile) > 0: date = Line.stringdate() print >> outfile, "# Rejects FROM %s on %s" % (originalFile, date) for p in rejectLines: print >> outfile, p.strip("\n") if verbose: print "Finished writing rejects: " + rejectFileName return True # end writeRejects # private use def updateAfterCount(self, opts, symbol): if not Line.matchedSymbolTail(symbol, opts.matchSyms): # here we assume the real symbol block comes last. works for uses in f90 return 0 if opts.language in ['cxx','python','f77','f90','java']: