Ejemplo n.º 1
0
    def createItems(self, parentItem, tree, data, parentPath="", rootPath=""):

        loadedItems = self.loadedItems
        itemCls = self.itemClass

        for current, children in tree.iteritems():

            p = pathJoin(parentPath, current)

            bBypassItem = False
            if rootPath:
                rp = pathRelativeTo(p, rootPath)
                if (rp == ".") or (".." in rp):
                    bBypassItem = True

            if bBypassItem:
                item = parentItem
            elif p in loadedItems:
                item = loadedItems[p]
            else:
                kwargs = data.get(p, {}).copy()
                texts = parentItem.columnCount() * [""]
                texts[0] = current
                texts = kwargs.pop("texts", texts)

                item = itemCls(parentItem, texts, **kwargs)

                loadedItems[p] = item

            if children:
                self.createItems(item, children, data, p, rootPath=rootPath)
Ejemplo n.º 2
0
    def walk(self, parentPath="", rootPath=""):

        for sChild, children in self.iteritems():

            p = pathJoin(parentPath, sChild)

            bYield = True
            if rootPath:
                rp = pathRelativeTo(p, rootPath)
                if (rp == ".") or (".." in rp):
                    bYield = False

            if bYield:
                yield p, children

            for cp in children.walk(p, rootPath):
                yield cp
Ejemplo n.º 3
0
    def iterPaths(self, parentPath="", rootPath=""):

        for sChild, children in self.iteritems():

            p = pathJoin(parentPath, sChild)

            bYield = True
            if rootPath:
                rp = pathRelativeTo(p, rootPath)
                if (rp == ".") or (".." in rp):
                    bYield = False

            if bYield:
                yield p

            for cp in children.iterPaths(p, rootPath):
                yield cp
Ejemplo n.º 4
0
    def dbToRelPath(self, sDbPath):

        sDbPath = pathNorm(sDbPath)
        sRelPath = pathRelativeTo(sDbPath, pathNorm(self.dbPath()))
        return sRelPath
Ejemplo n.º 5
0
 def absToRelPath(self, sAbsPath):
     return pathRelativeTo(sAbsPath, self.absPath())