def itemAdded(self, item): if isIpnsPath(item.path): itemName = item.path elif isIpfsPath(item.path): itemName = item.ipfsPath.basename else: itemName = item.path nMenu = QMenu(shortPathRepr(itemName), self) nMenu.setToolTipsVisible(True) nMenu.setToolTip(item.path) nMenu.triggered.connect(self.onHistoryItemClicked) self.menu.addMenu(nMenu) actionOpen = QAction(iClipItemOpen(), self) actionOpen.setToolTip(item.path) actionOpen.setData(item) actionSetCurrent = QAction(iClipItemSetCurrent(), self) actionSetCurrent.setData(item) actionSetCurrent.setToolTip(item.path) nMenu.addAction(actionOpen) nMenu.addAction(actionSetCurrent) def changeIcons(item, nMenu, aOpen): nMenu.setIcon(item.mimeIcon) aOpen.setIcon(item.mimeIcon) item.mimeIconAvailable.connect( functools.partial(changeIcons, item, nMenu, actionOpen)) self.updateToolTip()
def path(self, rscPath): if isinstance(rscPath, str) and isIpfsPath(rscPath): path = stripIpfs(rscPath.rstrip('/')).replace('/', '_') comps = path.split('/') if len(comps) > 0: containerId = comps[0][0:8] containerPath = os.path.join(self.metaDbPath, containerId) metaPath = os.path.join(containerPath, path) return containerPath, metaPath, os.path.exists(metaPath) return None, None, False
def ipfspathnorm(input): if isinstance(input, str): if cidValid(input): return joinIpfs(input) elif isIpfsPath(input) or isIpnsPath(input): return input