本文整理汇总了Python中openalea.core.pkgmanager.PackageManager.get_pkg_data方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.get_pkg_data方法的具体用法?Python PackageManager.get_pkg_data怎么用?Python PackageManager.get_pkg_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openalea.core.pkgmanager.PackageManager
的用法示例。
在下文中一共展示了PackageManager.get_pkg_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mimeData
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_pkg_data [as 别名]
def mimeData(self, modelIndexes):
item = self.itemFromIndex(modelIndexes[0])
mimeData = QtGui.QStandardItemModel.mimeData(self, modelIndexes)
(pkg_id, factory_id, mimetype) = self.get_item_info(item)
# -- marshall package and factory to the data stream, needed later --
itemData = QtCore.QByteArray()
dataStream = QtCore.QDataStream(itemData, QtCore.QIODevice.WriteOnly)
dataStream.writeString(pkg_id)
dataStream.writeString(factory_id)
mimeData.setData(mimetype, itemData)
# -- build an url --
factory = PackageManager()[pkg_id][factory_id]
if isinstance(factory, DataFactory):
url = QtCore.QUrl.fromLocalFile(factory.get_pkg_data().repr)
else:
query = ["fac="+factory_id]
ftname = type(factory).__name__
query.append("ft="+ftname)
query = reduce(lambda x,y:"&".join((x,y)), query)
url = QtCore.QUrl("oa://local/"+pkg_id+"?"+query)
mimeData.setUrls([url])
return mimeData