コード例 #1
0
    def getLink(self, path):
        relpath = plugins.relpath(self.summaryPageName, self.location, normalise=False)
        if "/" not in relpath:
            return path

        currLocation = self.location
        newParts = []
        for part in reversed(os.path.dirname(relpath).split("/")):
            if part == "..":
                currLocation, localName = os.path.split(currLocation)
                newParts.append(localName)
            else:
                newParts.append("..")
        return "/".join(newParts) + "/" + path
コード例 #2
0
ファイル: testoverview.py プロジェクト: scutse/texttest
 def writePages(self):
     plugins.log.info("Writing overview pages...")
     fileToUrl = self.getConfigValue("file_to_url", allSubKeys=True)
     for pageFile, (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 tag, details in self.pagesDetails.items():
         pageName = getDetailPageName(self.pageVersion, tag)
         details.write(os.path.join(self.pageDir, pageName))
         plugins.log.info("wrote: '" + pageName + "'")
     self.writeCommentListPage()
コード例 #3
0
ファイル: utils.py プロジェクト: libuda/texttest
def directorySerialise(dirName, ignoreLinks=False):
    text = ""
    for root, _, files in os.walk(dirName):
        for fn in sorted(files):
            path = os.path.join(root, fn)
            if not os.path.islink(path):
                relpath = plugins.relpath(path, dirName)
                text += fileText + " " + relpath + "\n"
                with open(path) as f:
                    text += f.read()
                if not text.endswith("\n"):
                    text += "\n"
                text += endPrefix + fileText + "\n"
    text += endPrefix + dirText
    return text
コード例 #4
0
    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)
            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, content, 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)
        self.treeView.expand_all()

        if len(self.pages) > 0:
            firstFile = self.pages[0][0]
            iterValid, 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)
コード例 #5
0
 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)
コード例 #6
0
 def makeRelPath(self, arg):
     if os.path.isabs(arg):
         relpath = plugins.relpath(arg, self.vcsDirectory)
         if relpath:
             return relpath
     return arg