コード例 #1
0
    def createTree(self, pathData, rootPath=""):

        pathItems = tuple(((pathNorm(d.pop("path")), d) for d in pathData))
        tree = OrderedTree.fromPaths(t[0] for t in pathItems)

        self.createItems(self, tree, dict(pathItems), rootPath=rootPath)
        self.resizeAllColumns()
コード例 #2
0
def launch(rootDirList, update=False, dryRun=True, project="", dialogParent=None):

    global TREE_ITEM_DCT
    TREE_ITEM_DCT = {}

    app = qtGuiApp()
    if not app:
        app = QtGui.QApplication(sys.argv)

    proj = initProject(project)

    dlg = QuickTreeDialog(dialogParent)
    treeWdg = dlg.treeWidget
    treeWdg.setHeaderLabels(("Entity Name", "Infos"))

    missingPathItems = listMissingPathItems(rootDirList, update=update)

    badEntityList = []
    treeDataList = []
    for damEntity, sMissingPaths in missingPathItems:

        if isinstance(damEntity, basestring):
            p = pathJoin("Errors", damEntity)
            badEntityList.append({"path":p, "texts":[damEntity, sMissingPaths],
                                  "flags":Qt.ItemIsEnabled,
                                  "roles":{Qt.ForegroundRole:(1, QtGui.QBrush(Qt.red))}
                                })
            continue

        drcLib = proj.getLibrary("public", damEntity.libraryName)
        sLibPath = drcLib.absPath()
        sEntityTitle = damEntity.sgEntityType + 's'

        sEntityPath = damEntity.getPath("public")
        sEntiTreePath = re.sub("^" + sLibPath, sEntityTitle, sEntityPath)

        roleData = {Qt.UserRole:(0, damEntity)}
        treeDataList.append({"path":sEntiTreePath, "flags":None, "roles":roleData})

        sTreePathList = tuple(re.sub("^" + sLibPath, sEntityTitle, p)
                              for p in sMissingPaths)

        tree = OrderedTree.fromPaths(sTreePathList)

        for sTreePath in tree.iterPaths(rootPath=sEntiTreePath):
            treeDataList.append({"path":sTreePath, "flags":Qt.NoItemFlags})

    treeWdg.createTree(badEntityList)

    treeWdg.defaultFlags |= Qt.ItemIsTristate
    treeWdg.defaultRoles = {Qt.CheckStateRole:(0, Qt.Unchecked)}
    treeWdg.createTree(treeDataList)

    topItemCount = treeWdg.topLevelItemCount()
    if topItemCount == 1:
        curItem = treeWdg.topLevelItem(0)
        treeWdg.setRootIndex(treeWdg.indexFromItem(curItem))
        while curItem.childCount() == 1:
            curItem = curItem.child(0)
            curItem.setExpanded(True)
    else:
        for i in xrange(topItemCount):
            treeWdg.topLevelItem(i).setExpanded(True)

    dlg.show()

    while True:

        bOk = dlg.exec_()
        if not bOk:
            return

        bApply = False

        flags = (QTreeWidgetItemIterator.Checked | QTreeWidgetItemIterator.Enabled)
        treeIter = QTreeWidgetItemIterator(treeWdg, flags)
        damEntities = tuple(it.value().data(0, Qt.UserRole) for it in treeIter)
        damAssets = tuple(e for e in damEntities if isinstance(e, DamAsset))
        damShots = tuple(e for e in damEntities if isinstance(e, DamShot))
        if damAssets or damShots:

            sMsg = "Create directories and files for:\n"
            if damAssets:
                sMsg += "\n     - {} Assets".format(len(damAssets))

            if damShots:
                sMsg += "\n     - {} Shots".format(len(damShots))

            sConfirm = confirmDialog(title="WARNING !",
                                     message=sMsg,
                                     button=("Yes", "No"),
                                     defaultButton="No",
                                     cancelButton="No",
                                     dismissString="No",
                                     icon="warning",
                                    )

            if sConfirm == "Yes":
                bApply = True
                break

    if bApply:

        entityDirList = len(damEntities) * [None]

        for i, damEntity in enumerate(damEntities):
            if not damEntity:
                continue
            damEntity.createDirsAndFiles(dryRun=dryRun, checkDb=False)
            entityDirList[i] = damEntity.getResource("public", "entity_dir")

        for drcDir in entityDirList:
            if drcDir:
                drcDir.setSyncRules(drcDir.syncRules)
コード例 #3
0
from pytd.util.utiltypes import OrderedTree


srcPaths = ["A/B/C", "A/C/D", "A/C/D/E", "A/C/D/F", "A/B/D/F", "A/A/D/F", "A/C/D/G"]

tree = OrderedTree.fromPaths(srcPaths)
print tree

for p in tree.iterPaths(rootPath="A/C/D"):
    print p
コード例 #4
0
from pytd.util.utiltypes import OrderedTree


srcPaths = ["A/B/C", "A/C/D", "A/C/D/E", "A/C/D/F", "A/B/D/F", "A/A/D/F", "A/C/D/G"]

tree = OrderedTree.fromPaths(srcPaths)
print tree

for p in tree.iterPaths(rootPath="A/C/D"):
    print p