本文整理汇总了Python中micropsi_core.runtime.get_available_worlds函数的典型用法代码示例。如果您正苦于以下问题:Python get_available_worlds函数的具体用法?Python get_available_worlds怎么用?Python get_available_worlds使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_available_worlds函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_object_properties
def test_set_object_properties(test_world):
world = runtime.get_available_worlds()[test_world]
runtime.add_worldobject(test_world, "Default", (10, 10), uid='foobar', name='foobar', parameters={})
runtime.set_worldobject_properties(test_world, "foobar", position=(5, 5))
assert world.objects["foobar"].position == (5, 5)
assert world.data['objects']['foobar']['position'] == (5, 5)
assert runtime.get_world_view(test_world, -1)['objects']['foobar']['position'] == (5, 5)
示例2: world_list
def world_list(current_world=None):
user_id, permissions, token = get_request_data()
worlds = runtime.get_available_worlds()
return template("nodenet_list", type="world", user_id=user_id,
current=current_world,
mine=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].owner == user_id),
others=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].owner != user_id))
示例3: _add_world_list
def _add_world_list(template_name, **params):
worlds = runtime.get_available_worlds()
if request.query.get('select_world') and request.query.get('select_world') in worlds:
current_world = request.query.get('select_world')
response.set_cookie('selected_world', current_world)
else:
current_world = request.get_cookie('selected_world')
world_type = ""
world_assets = {}
world_template = ""
if current_world:
world_obj = runtime.load_world(current_world)
world_type = world_obj.__class__.__name__
if hasattr(world_obj, 'assets'):
world_assets = world_obj.assets
if 'template' in world_assets:
import inspect
basedir = os.path.dirname(inspect.getfile(world_obj.__class__))
with open(os.path.join(basedir, world_assets['template'])) as fp:
world_template = template(fp.read(), world_assets=world_assets)
return template(template_name, current=current_world,
mine=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].get('owner') == params['user_id']),
others=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].get('owner') != params['user_id']),
world_type=world_type,
world_assets=world_assets,
world_template=world_template,
**params)
示例4: test_add_worldobject
def test_add_worldobject(test_world):
world = runtime.get_available_worlds()[test_world]
runtime.add_worldobject(test_world, "Default", (10, 10), uid='foobar', name='foobar', parameters={})
assert "foobar" in world.data['objects']
assert "foobar" in world.objects
runtime.save_world(test_world)
runtime.revert_world(test_world)
assert "foobar" in world.data['objects']
assert "foobar" in world.objects
示例5: edit_nodenet
def edit_nodenet():
user_id, permissions, token = get_request_data()
# nodenet_id = request.params.get('id', None)
title = 'Edit Nodenet' if id is not None else 'New Nodenet'
return template("nodenet_form.tpl", title=title,
# nodenet_uid=nodenet_uid,
nodenets=runtime.get_available_nodenets(),
templates=runtime.get_available_nodenets(),
worlds=runtime.get_available_worlds(),
version=VERSION, user_id=user_id, permissions=permissions)
示例6: edit_nodenet
def edit_nodenet():
user_id, permissions, token = get_request_data()
nodenet_uid = request.params.get('id')
title = 'Edit Agent' if nodenet_uid is not None else 'New Agent'
return template("nodenet_form.tpl", title=title,
nodenet=None if not nodenet_uid else runtime.get_nodenet(nodenet_uid).metadata,
devices=runtime.get_devices(),
nodenets=runtime.get_available_nodenets(),
worldtypes=runtime.get_available_world_types(),
templates=runtime.get_available_nodenets(),
worlds=runtime.get_available_worlds(),
version=VERSION, user_id=user_id, permissions=permissions)
示例7: test_world
def test_world(request):
global world_uid
worlds = micropsi.get_available_worlds("Pytest User")
if worlds:
world_uid = list(worlds.keys())[0]
else:
success, world_uid = micropsi.new_world("World of Pain", "Island", "Pytest User")
def fin():
if DELETE_TEST_FILES_ON_EXIT:
micropsi.delete_world(world_uid)
request.addfinalizer(fin)
return world_uid
示例8: test_new_world
def test_new_world(resourcepath, test_world):
success, world_uid = micropsi.new_world("Waterworld", "World", owner="tester")
assert success
assert world_uid != test_world
world_properties = micropsi.get_world_properties(world_uid)
assert world_properties["name"] == "Waterworld"
w_path = os.path.join(resourcepath, runtime.WORLD_DIRECTORY, world_uid + ".json")
assert os.path.exists(w_path)
# get_available_worlds
worlds = micropsi.get_available_worlds()
myworlds = micropsi.get_available_worlds("tester")
assert test_world in worlds
assert world_uid in worlds
assert world_uid in myworlds
assert test_world not in myworlds
# delete_world
micropsi.delete_world(world_uid)
assert world_uid not in micropsi.get_available_worlds()
assert not os.path.exists(w_path)
示例9: test_world
def test_world(request):
global world_uid
worlds = micropsi.get_available_worlds("Pytest User")
if world_uid not in worlds:
success, world_uid = micropsi.new_world("World of Pain", "Island", "Pytest User", uid=world_uid)
def fin():
try:
micropsi.revert_world(world_uid)
except KeyError:
pass # world was deleted in test
request.addfinalizer(fin)
return world_uid
示例10: _add_world_list
def _add_world_list(template_name, **params):
worlds = runtime.get_available_worlds()
if request.query.get('select_world') and request.query.get('select_world') in worlds:
current_world = request.query.get('select_world')
response.set_cookie('selected_world', current_world)
else:
current_world = request.get_cookie('selected_world')
if current_world in worlds and hasattr(worlds[current_world], 'assets'):
world_assets = worlds[current_world].assets
else:
world_assets = {}
return template(template_name, current=current_world,
mine=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].owner == params['user_id']),
others=dict((uid, worlds[uid]) for uid in worlds if worlds[uid].owner != params['user_id']),
world_assets=world_assets, **params)
示例11: get_available_worlds
def get_available_worlds(user_id=None):
""" Return a dict of available worlds, optionally filtered by owner)"""
data = {}
for uid, world in runtime.get_available_worlds(user_id).items():
data[uid] = dict(
uid=world.uid,
name=world.name,
world_type=world.world_type,
filename=world.filename,
config={},
owner=world.owner) # fixme
# ok I might but couldcha tell me more about wat is broken wid ya?
if hasattr(world, 'config'):
data[uid]['config'] = world.config
return True, data
示例12: get_available_worlds
def get_available_worlds(user_id=None):
data = {}
for uid, world in runtime.get_available_worlds(user_id).items():
data[uid] = {'name': world.name} # fixme
return True, data
示例13: create_worldadapter_selector
def create_worldadapter_selector(world_uid):
nodenets = runtime.get_available_nodenets()
worlds = runtime.get_available_worlds()
return template("worldadapter_selector", world_uid=world_uid,
nodenets=nodenets, worlds=worlds)
示例14: create_new_nodenet_form
def create_new_nodenet_form():
user_id, permissions, token = get_request_data()
nodenets = runtime.get_available_nodenets()
worlds = runtime.get_available_worlds()
return template("nodenet_form", user_id=user_id, template="None",
nodenets=nodenets, worlds=worlds)
示例15: create_worldadapter_selector
def create_worldadapter_selector(world_uid=None):
return template("worldadapter_selector",
world_uid=world_uid,
nodenets=runtime.get_available_nodenets(),
worlds=runtime.get_available_worlds(),
worldtypes=runtime.get_available_world_types())