Пример #1
0
def toDisplayText(value, sep=", "):

    if value in (None, False, "undefined"):
        return ""

    elif value is True:
        return "on"

    elif isinstance(value, datetime.date):
        try:
            return value.strftime("%Y-%m-%d %H:%M")
        except ValueError:
            return ""

    elif isinstance(value, MemSize):
        return "{0:.2cM}".format(value)

    elif isinstance(value, basestring):
        return toUnicode(value)

    elif isIterable(value):
        return sep.join((toDisplayText(v, sep) for v in value))

    else:
        return toUnicode(value)
Пример #2
0
def toDisplayText(value, sep=", "):

    if value in (None, False, "undefined"):
        return ""

    elif value is True:
        return "on"

    elif isinstance(value, datetime.date):
        try:
            return value.strftime("%Y-%m-%d %H:%M")
        except ValueError:
            return ""

    elif isinstance(value, MemSize):
        return "{0:.2cM}".format(value)

    elif isinstance(value, basestring):
        return toUnicode(value)

    elif isIterable(value):
        return sep.join((toDisplayText(v, sep) for v in value))

    else:
        return toUnicode(value)
Пример #3
0
def toEditText(value, sep=", "):

    if value is None:
        return ""

    elif isinstance(value, basestring):
        return toUnicode(value)

    elif isinstance(value, bool):
        return toUnicode(int(value))

    elif isIterable(value):
        return sep.join((toEditText(v, sep) for v in value))

    else:
        return toUnicode(value)
Пример #4
0
def toEditText(value, sep=", "):

    if value is None:
        return ""

    elif isinstance(value, basestring):
        return toUnicode(value)

    elif isinstance(value, bool):
        return toUnicode(int(value))

    elif isIterable(value):
        return sep.join((toEditText(v, sep) for v in value))

    else:
        return toUnicode(value)
Пример #5
0
def pathJoin(*args):
    try:
        p = osp.join(*args)
    except UnicodeDecodeError:
        p = osp.join(*tuple(toUnicode(arg) for arg in args))

    return pathNorm(p, case=False, keepEndSlash=True)
Пример #6
0
def pathJoin(*args):
    try:
        p = osp.join(*args)
    except UnicodeDecodeError:
        p = osp.join(*tuple(toUnicode(arg) for arg in args))

    return pathNorm(p, case=False, keepEndSlash=True)
Пример #7
0
    def getPrptiesFromUiCategory(self, categoryKey):

        if isinstance(categoryKey, basestring):
            sCategoryKey = categoryKey
        elif isinstance(categoryKey, int):
            sCategoryKey = toUnicode(self.uiCategoryList[categoryKey])

        return self.uiCategoryDct.get(sCategoryKey, ())
Пример #8
0
def pathRename(sSrcPath, sDstPath):
    try:
        os.rename(sSrcPath, sDstPath)
    except WindowsError as e:
        if hostApp() == "maya":
            raise WindowsError(toUnicode("code {} - {}: {}".format(e.args[0], e.strerror , sSrcPath)))
        else:
            raise WindowsError(e.args[0], "{}: {}".format(e.strerror , sSrcPath))
    def getPrptiesFromUiCategory(self, categoryKey):

        if isinstance(categoryKey, basestring):
            sCategoryKey = categoryKey
        elif isinstance(categoryKey, int):
            sCategoryKey = toUnicode(self.uiCategoryList[categoryKey])

        return self.uiCategoryDct.get(sCategoryKey, ())
Пример #10
0
def pathRename(sSrcPath, sDstPath):
    try:
        os.rename(sSrcPath, sDstPath)
    except WindowsError as e:
        if hostApp() == "maya":
            raise WindowsError(toUnicode("code {} - {}: {}".format(e.args[0], e.strerror , sSrcPath)))
        else:
            raise WindowsError(e.args[0], "{}: {}".format(e.strerror , sSrcPath))
Пример #11
0
    def castToWrite(self, in_value):
        value = DbBaseProperty.castToWrite(self, in_value)

        if self.isMulti():

            if value and isinstance(value, basestring):
                values = _STR_TO_LIST_REXP.findall(value)
            else:
                values = argToList(value)

            value = u",".join(toUnicode(v) for v in values) if value else None
        else:
            value = toUnicode(value)

        if value:
            value = value.replace(u"%", u"percent")

        return value
Пример #12
0
    def getValue(self):

        style = self._style
        if style == "text":
            oValue = toUnicode(self.prompt.text())

        elif style in ("integer", "float"):
            oValue = self.prompt.value()

        return oValue
Пример #13
0
    def getValue(self):

        style = self._style
        if style == "text":
            oValue = toUnicode(self.prompt.text())

        elif style in ("integer", "float"):
            oValue = self.prompt.value()

        return oValue
Пример #14
0
def launch(dryRun=True, project=""):

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

    sProject = os.environ["DAVOS_INIT_PROJECT"] if not project else project
    proj = DamProject(sProject)
    print sProject.center(80, "-")

    dbNodeDct = {}

    sFieldSet = set()

    print "Querying all dbnodes..."
    dbNodeList = proj.findDbNodes()
    print "Got {} dbnodes.".format(len(dbNodeList))

    for dbnode in dbNodeList:
        sFieldSet.update(dbnode._data.iterkeys())
        dbNodeDct.setdefault(dbnode.file.lower(), []).append(dbnode)

    dlg = QuickTreeDialog()
    treeWdg = dlg.treeWidget

    sFieldList = sorted(sFieldSet)
    sFieldList.remove("file")
    sFieldList.remove("#parent")
    sFieldList.insert(0, "file")

    treeWdg.setHeaderLabels(sFieldList)
    treeWdg.setTextElideMode(Qt.ElideLeft)

    topLevelItemDct = {}
    for sDbPath, nodes in dbNodeDct.iteritems():
        x = len(nodes)
        if x > 1:
            nodes = sorted(nodes, key=lambda n:int(n.time) * .001, reverse=True)

            if sDbPath not in topLevelItemDct:
                topItem = TreeItem(treeWdg, [sDbPath])
                topLevelItemDct[sDbPath] = topItem
            else:
                topItem = topLevelItemDct[sDbPath]

            for n in nodes:
                sTime = (datetime.fromtimestamp(int(n.time) / 1000)
                      .strftime(u"%Y-%m-%d %H:%M"))
                n._data["time"] = sTime

                itemData = tuple(toUnicode(n._data.get(f, "")) for f in sFieldList)
                print itemData[0]
                item = TreeItem(topItem, itemData)
                item.setCheckState(0, Qt.Unchecked)
                item.setData(0, Qt.UserRole, n)

    treeWdg.expandAll()
    for c in xrange(treeWdg.columnCount()):
        treeWdg.resizeColumnToContents(c)

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

    itemIter = QTreeWidgetItemIterator(treeWdg, QTreeWidgetItemIterator.Checked)
    toDeleteNodes = [item.value().data(0, Qt.UserRole) for item in itemIter]
    if toDeleteNodes:
        sMsg = "Delete these {} Db nodes ???".format(len(toDeleteNodes))
        sConfirm = confirmDialog(title="WARNING !",
                                 message=sMsg,
                                 button=("Yes", "No"),
                                 defaultButton="No",
                                 cancelButton="No",
                                 dismissString="No",
                                 icon="warning",
                                )

        if sConfirm == "Yes":
            for n in toDeleteNodes:
                print "Deleting", n.file, n._data
                if not dryRun:
                    n.delete()
Пример #15
0
    def updatePathBar(self, index):

        pathToolBar = self.pathToolBar
        childrenView = self.childrenView

        pathToolBar.actionTriggered.disconnect(self.pathActionTriggered)

        def restore():
            pathToolBar.actionTriggered.connect(self.pathActionTriggered)

        pathToolBar.clear()

#        if index.isValid():
#            print "\n", index.model().itemFromIndex(index), index.model()

        if index.column() != 0:
            parentIndex = index.sibling(index.row(), 0)
        else:
            parentIndex = index

        bBreak = False

        treeRoot = childrenView.model().invisibleRootItem()

        count = 0
        prevAction = None
        while True:

            if not parentIndex.isValid():
                parentItem = treeRoot
                sLabel = "Root"
                bBreak = True
            else:
                model = parentIndex.model()
                parentItem = model.itemFromIndex(parentIndex)
                sLabel = toUnicode(model.data(parentIndex, Qt.DisplayRole))

#            print parentItem

            viewIndex = childrenView.mappedIdx(parentIndex)
            icon = viewIndex.data(Qt.DecorationRole)
            if not icon:
                icon = QtGui.QIcon()

            if count == 0:
                curAction = pathToolBar.addAction(icon, sLabel)
            else:
                curAction = pathToolBar.addAction(icon, sLabel)
                pathToolBar.insertAction(prevAction, curAction)

            pathToolBar.setActionData(curAction, parentItem)

            if icon.isNull():
                toolBtn = pathToolBar.widgetForAction(curAction)
                toolBtn.setArrowType(Qt.RightArrow)

            if bBreak:
                break

            prevAction = curAction
            parentIndex = parentIndex.parent()

            count += 1

        restore()
Пример #16
0
 def castToWrite(self, in_value):
     value = DbBoolProperty.castToWrite(self, in_value)
     return toUnicode(value) if value else None
Пример #17
0
 def getValue(self):
     return toUnicode(self.text())