本文整理匯總了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")