def createTreeView(self): # Columns are: 0 - Tree node name # 1 - Content (output from VCS) for the corresponding file # 2 - Info. If the plugin wants to show two columns, this # is shown in the second column. If not it should be empty. # 3 - Full path to the file corresponding to the node # 4 - Should the row be visible? self.treeModel = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN) self.filteredTreeModel = self.treeModel.filter_new() self.filteredTreeModel.set_visible_column(4) rootDir = self.getRootPath() fileToIter = {} for fileName, content, info in self.pages: label = plugins.relpath(fileName, rootDir) self.diag.info("Adding info for file " + label) utfContent = guiutils.convertToUtf8(content) path = label.split(os.sep) currentFile = rootDir prevIter = None for element in path: currentFile = os.path.join(currentFile, element) currentInfo = "" currentElement = element.strip(" \n") if currentFile == fileName: currentInfo = info else: currentElement = "<span weight='bold'>" + currentElement + "</span>" currIter = fileToIter.get(currentFile) if currIter is None: newRow = (currentElement, utfContent, currentInfo, currentFile, True) currIter = self.treeModel.append(prevIter, newRow) fileToIter[currentFile] = currIter prevIter = currIter self.treeView = gtk.TreeView(self.filteredTreeModel) self.treeView.set_name("VCS " + self.cmdName + " info tree") self.treeView.set_enable_search(False) fileRenderer = gtk.CellRendererText() fileColumn = gtk.TreeViewColumn("File", fileRenderer, markup=0) fileColumn.set_resizable(True) self.treeView.append_column(fileColumn) self.treeView.set_expander_column(fileColumn) if self.getResultDialogTwoColumnsInTreeView(): infoRenderer = gtk.CellRendererText() self.infoColumn = custom_widgets.ButtonedTreeViewColumn(self.getResultDialogSecondColumnTitle(), infoRenderer, markup=2) self.infoColumn.set_resizable(True) self.treeView.append_column(self.infoColumn) self.treeView.get_selection().set_select_function(self.canSelect) self.treeView.expand_all() if len(self.pages) > 0: firstFile = self.pages[0][0] firstIter = self.filteredTreeModel.convert_child_iter_to_iter(fileToIter[firstFile]) self.updateForIter(firstIter) self.treeView.get_selection().select_iter(firstIter) self.treeView.get_selection().connect("changed", self.showOutput)
def backupPreviousData(self, test): writeDir = test.getDirectory(temporary=1) newBackupPath, oldBackupPaths = self.findBackupPaths(test) localTmpDir = os.path.join(os.path.dirname(writeDir), os.path.basename(newBackupPath)) os.rename(writeDir, localTmpDir) test.makeWriteDirectory() for oldBackupPath in oldBackupPaths: currLocation = os.path.join(localTmpDir, plugins.relpath(oldBackupPath, writeDir)) os.rename(currLocation, oldBackupPath) os.rename(localTmpDir, newBackupPath)
def writePages(self): plugins.log.info("Writing overview pages...") for pageFile, (resourceName, page) in self.pagesOverview.items(): page.write(pageFile) plugins.log.info("wrote: '" + plugins.relpath(pageFile, self.pageDir) + "'") plugins.log.info("Writing detail pages...") for resourceName in self.resourceNames: for tag, details in self.pagesDetails.items(): pageName = getDetailPageName(self.pageVersion, tag) relPath = os.path.join(resourceName, pageName) details.write(os.path.join(self.pageDir, relPath)) plugins.log.info("wrote: '" + relPath + "'")
def writePages(self): plugins.log.info("Writing overview pages...") fileToUrl = self.getConfigValue("file_to_url", allSubKeys=True) for pageFile, (resourceName, page, _) in self.pagesOverview.items(): page.write(pageFile) plugins.log.info("wrote: '" + plugins.relpath(pageFile, self.pageDir) + "'") if fileToUrl: url = convertToUrl(pageFile, fileToUrl) plugins.log.info("(URL is " + url + ")") plugins.log.info("Writing detail pages...") for resourceName in self.resourceNames: for tag, details in self.pagesDetails.items(): pageName = getDetailPageName(self.pageVersion, tag) relPath = os.path.join(resourceName, pageName) details.write(os.path.join(self.pageDir, relPath)) plugins.log.info("wrote: '" + relPath + "'")
def expandCollations(self, test, coll): newColl = seqdict() self.diag.info("coll initial:" + str(coll)) for targetPattern, sourcePatterns in coll.items(): if not glob.has_magic(targetPattern): newColl[targetPattern] = sourcePatterns continue # add each file to newColl by transferring wildcards across for sourcePattern in sourcePatterns: for sourcePath in self.findPaths(test, sourcePattern): # Use relative paths: easier to debug and SequenceMatcher breaks down if strings are longer than 200 chars relativeSourcePath = plugins.relpath(sourcePath, test.getDirectory(temporary=1)) newTargetStem = self.makeTargetStem(targetPattern, sourcePattern, relativeSourcePath) self.diag.info("New collation to " + newTargetStem + " : from " + relativeSourcePath) newColl.setdefault(newTargetStem, []).append(sourcePath) return newColl
def findBugFileTest(self, filePath): testDir = os.path.dirname(filePath) for suite in self.rootSuites: if testDir.startswith(suite.getDirectory()): relPath = plugins.relpath(testDir, suite.getDirectory()) return suite.findSubtestWithPath(relPath)