本文整理汇总了Python中openalea.core.pkgmanager.PackageManager.create_user_package方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.create_user_package方法的具体用法?Python PackageManager.create_user_package怎么用?Python PackageManager.create_user_package使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openalea.core.pkgmanager.PackageManager
的用法示例。
在下文中一共展示了PackageManager.create_user_package方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nodewriter
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import create_user_package [as 别名]
def test_nodewriter():
"""test node writer"""
setup_module()
pm = PackageManager()
pm.clear()
pm.init()
# Package
metainfo = {'version': '0.0.1',
'license': 'CECILL-C',
'authors': 'OpenAlea Consortium',
'institutes': 'INRIA/CIRAD',
'description': 'Base library.',
'url': 'http://openalea.gforge.inria.fr'}
package1 = pm.create_user_package("MyTestPackage", \
metainfo, os.path.curdir)
assert package1 != None
nf = package1.create_user_node(name="mynode",
category='test',
description="descr",
inputs=(),
outputs=(),
)
package1.write()
pm.init()
newsg = pm.get_node('MyTestPackage', 'mynode')
package1.remove_files()
示例2: test_compositenodewriter
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import create_user_package [as 别名]
def test_compositenodewriter():
setup_module()
pm = PackageManager()
pm.init()
sg = CompositeNode(inputs=[dict(name="%d" % i) for i in xrange(3)],
outputs=[dict(name="%d" % i) for i in xrange(4)],
)
# build the compositenode factory
addid = sg.add_node(pm.get_node("pkg_test", "+"))
val1id = sg.add_node(pm.get_node("pkg_test", "float"))
val2id = sg.add_node(pm.get_node("pkg_test", "float"))
val3id = sg.add_node(pm.get_node("pkg_test", "float"))
sg.connect(val1id, 0, addid, 0)
sg.connect(val2id, 0, addid, 1)
sg.connect(addid, 0, val3id, 0)
sg.connect(val3id, 0, sg.id_out, 0)
sgfactory = CompositeNodeFactory("addition")
sg.to_factory(sgfactory)
# Package
metainfo = {'version': '0.0.1',
'license': 'CECILL-C',
'authors': 'OpenAlea Consortium',
'institutes': 'INRIA/CIRAD',
'description': 'Base library.',
'url': 'http://openalea.gforge.inria.fr'}
package1 = pm.create_user_package("MyTestPackage",
metainfo, os.path.curdir)
package1.add_factory(sgfactory)
print package1.keys()
assert 'addition' in package1
package1.write()
sg = sgfactory.instantiate()
sg.node(val1id).set_input(0, 2.)
sg.node(val2id).set_input(0, 3.)
# evaluation
sg()
print sg.node(val3id).get_output(0)
assert sg.node(val3id).get_output(0) == 5.
print "nb vertices", len(sg)
assert len(sg) == 6
pm.init()
newsg = pm.get_node('MyTestPackage', 'addition')
print "nb vertices", len(newsg)
assert len(newsg) == 6
示例3: Session
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import create_user_package [as 别名]
class Session(Observed):
"""
A session is composed by different workspaces, and an user package.
A workspace is an open node
A session can be saved on disk.
"""
USR_PKG_NAME = "__my package__"
def __init__(self):
Observed.__init__(self)
self.workspaces = []
self.cworkspace = -1 # current workspace
self.graphViews = weakref.WeakKeyDictionary()
self.datapool = DataPool()
# Use dictionary
self.use_by_name = {}
self.use_by_interface = {}
self.pkgmanager = PackageManager()
self.empty_cnode_factory = CompositeNodeFactory("Workspace")
self.clipboard = CompositeNodeFactory("Clipboard")
self.init()
# gengraph
def simulate_workspace_addition(self):
for ws in self.workspaces:
self.notify_listeners(("workspace_added", ws))
#/gengraph
def get_current_workspace(self, ):
""" Return the current workspace object """
return self.workspaces[self.cworkspace]
ws = property(get_current_workspace)
def get_graph_views(self):
return self.graphViews.keys()
def add_graph_view(self, view):
self.graphViews[view] = None
def add_workspace(self, compositenode=None, notify=True):
"""
Open a new workspace in the session
if compositenode = None, create a new empty compositenode
"""
if compositenode is None:
compositenode = self.empty_cnode_factory.instantiate()
compositenode.set_caption("")
self.workspaces.append(compositenode)
elif(compositenode not in self.workspaces):
self.workspaces.append(compositenode)
else:
return compositenode
if(notify):
self.notify_listeners(("workspace_added", compositenode))
return compositenode
def close_workspace(self, index, notify=True):
""" Close workspace at index """
del self.workspaces[index]
if(notify):
self.notify_listeners()
def init(self, create_workspace=True):
""" Init the Session """
self.session_filename = None
#self.workspaces = []
# init pkgmanager
self.pkgmanager.find_and_register_packages()
# Create user package if needed
if (not self.pkgmanager.has_key(self.USR_PKG_NAME)):
try:
self.pkgmanager.create_user_package(self.USR_PKG_NAME, {})
except:
pass
if (create_workspace):
self.add_workspace()
self.cworkspace = 0
load_interfaces()
self.notify_listeners()
def clear(self, create_workspace=True):
#.........这里部分代码省略.........