本文整理汇总了Python中openalea.core.pkgmanager.PackageManager.search_node方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.search_node方法的具体用法?Python PackageManager.search_node怎么用?Python PackageManager.search_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openalea.core.pkgmanager.PackageManager
的用法示例。
在下文中一共展示了PackageManager.search_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_search
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import search_node [as 别名]
def test_search():
pkgman = PackageManager()
pkgman.load_directory("./")
assert 'Test' in pkgman
res = pkgman.search_node("sum")
print res
assert "sum" in res[0].name
示例2: NodeChooser
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import search_node [as 别名]
class NodeChooser(qt.QtGui.QDialog, ui_nodechooser.Ui_NodeChooser):
""" Dialog allowing to choose a node (package view) """
def __init__(self, parent):
from node_treeview import SearchListView, SearchModel
qt.QtGui.QDialog.__init__(self, parent)
ui_nodechooser.Ui_NodeChooser.__init__(self)
self.setupUi(self)
self.pman = PackageManager()
self.map = {}
def search(self, name='', nb_inputs=-1, nb_outputs=-1):
""" Add node to combo box selector corresponding to request
@param name
@param nb_inputs
@param nb_outputs
"""
res = self.pman.search_node(name, nb_inputs, nb_outputs)
strs = []
for f in res:
key = "%s.%s" % (f.package.get_id().lower(), f.name)
self.map[key] = f
strs.append(key)
strs.sort()
self.comboBox.addItems(strs)
def get_selection(self):
""" Return selected factory """
s = str(self.comboBox.currentText())
if(self.map.has_key(s)):
return self.map[s]
return None
def accept(self):
""" Validate result """
s = str(self.comboBox.currentText())
if(self.map.has_key(s)):
qt.QtGui.QDialog.accept(self)
else:
qt.QtGui.QMessageBox.warning(self, "Error", "Unknown component name")