def getExportInfo (module, mainName = None, source = None): if mainName is None: try: mainName = yutil.findFileExt ('h' + module [1:], ['.hpp', '.h']) except yutil.notFound: return [] if source is None: source = yutil.openFile (module).read () part = getDefinePart (source) currentEntry = [os.path.basename (mainName), '', ''] result = [currentEntry] rex = re.compile ('[(][*] *ptocExport +([^ *]+) *[*][)]') pos = 0 match = rex.search (part, pos) while match: currentEntry [1] = currentEntry [1] + part [pos:match.start ()] fname = fileutil.basename (match.group (1)) + '.h' currentEntry = findCurrentEntry (result, fname) pos = match.end () match = rex.search (part, pos) currentEntry [1] = currentEntry [1] + part [pos:] for entry in result: declarations = entry [1] entry [2] = md5.new (declarations).digest () return result
def main(options, args): """Extracts comments from C++ sources and generates HTML. """ bodyAttributes = parseAttributes(options.body, [('bgcolor', '#FFFFFF')]) weaver = NoWeaver() for arg in args: cppDoc = CppDoc(bodyAttributes) cppDoc.tabSize = options.tabsize cppDoc.doHighlight = options.highlight cppDocLib.strict = options.strict cppDoc.quoteHTML = options.quoteHTML cppDoc.weaver = weaver ok = cppDoc.readSource(File(arg), options.cleanForm) if ok: outfile = File( options.outdir).join(fileutil.basename(arg) + '.html') outname = os.path.join(options.outdir, fileutil.basename(arg) + '.html') cppDoc.genHTML(outfile)
def getOther(self): otherFile = yutil.findRelativeFile(self.relativePath, vpath=self.otherVPath) if otherFile is None: return self.createEmptyFile(self.relativePath, self.labels[2]) if self.renamer: base = fileutil.basename(otherFile) renamedFile = os.path.join(os.environ['TMP'], 'renamed.' + base) self.renamer.filterFile(otherFile, renamedFile) otherFile = renamedFile return otherFile
def createEmptyFile(self, fname, kind, fillFile=None): baseName = fileutil.basename(fname) fname = os.path.join(os.environ['TMP'], 'empty.' + kind + '.' + baseName) stream = open(fname, 'wt') if fillFile: data = open(fillFile, 'rt').read() else: data = '%s: %s does not exist\n' % (kind, baseName) stream.write(data) stream.close() return fname
def main(options, args): """compares two files side by side Allows to merge changes into one file. If only one file is given, then the latest Perforce revision is used. Colors: red lines deleted green lines added yellow lines changed Keys: n next difference p previous difference Ctrl-s save file Cursors left panel: right arrow merge changes into right panel Cursors right panel: X delete difference exchange revert change Options: """ if len(args) == 0: sys.stderr.write('at least one filename must be given\n') sys.exit(2) mine = args[0] if len(args) > 2: sys.stderr.write('only two files can be compared\n') sys.exit(2) if len(args) == 2: mine, other = fillDirArgs(mine, args[1]) otherFile, otherId = other, other elif options.branch: otherFile, otherId = getOtherBranch(mine, options.branch) else: otherFile, otherId = getCurrentPerforce(mine, options.revision) import diffTools.wdiffLib from fileutil import basename wdiff = diffTools.wdiffLib.WDiff(options) wdiff.addDiff(mine, otherFile) title = 'wp4diff: %s' % (basename(mine), ) wdiff.mainLoop(title, line=options.line, files=[otherId, mine])
def outfile (fname, options): fname = fileutil.basename (fname) + 'module.c' return os.path.join (options.outdir, fname)
def openNext (self): MultiFileStream.openNext (self) self.basename = fileutil.basename (self.fname)