コード例 #1
0
    def append(self, tHandle, pHandle, nwItem):
        """Add a new item to the end of the tree.
        """
        tHandle = checkHandle(tHandle, None, True)
        pHandle = checkHandle(pHandle, None, True)
        if tHandle is None:
            tHandle = self._makeHandle()

        logger.verbose("Adding item %s with parent %s" %
                       (str(tHandle), str(pHandle)))

        nwItem.setHandle(tHandle)
        nwItem.setParent(pHandle)

        self._projTree[tHandle] = nwItem
        self._treeOrder.append(tHandle)

        if nwItem.itemType == nwItemType.ROOT:
            logger.verbose("Item %s is a root item" % str(tHandle))
            self._treeRoots.append(tHandle)
            if nwItem.itemClass == nwItemClass.ARCHIVE:
                logger.verbose("Item %s is the archive folder" % str(tHandle))
                self._archRoot = tHandle

        if nwItem.itemType == nwItemType.TRASH:
            if self._trashRoot is None:
                logger.verbose("Item %s is the trash folder" % str(tHandle))
                self._trashRoot = tHandle
            else:
                logger.error("Only one trash folder allowed")

        self._setTreeChanged(True)

        return
コード例 #2
0
def testCheckHandle():
    assert checkHandle("None", 1, True) is None
    assert checkHandle("None", 1, False) == 1
    assert checkHandle(None, 1, True) is None
    assert checkHandle(None, 1, False) == 1
    assert checkHandle("47666c91c7ccf", None, False) == "47666c91c7ccf"
    assert checkHandle("h7666c91c7ccf", None, False) is None
コード例 #3
0
def testBaseCommon_CheckHandle():
    """Test the checkHandle function.
    """
    assert checkHandle("None", 1, True) is None
    assert checkHandle("None", 1, False) == 1
    assert checkHandle(None, 1, True) is None
    assert checkHandle(None, 1, False) == 1
    assert checkHandle("47666c91c7ccf", None, False) == "47666c91c7ccf"
    assert checkHandle("h7666c91c7ccf", None, False) is None