• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python runtime.get_available_worlds函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中micropsi_core.runtime.get_available_worlds函数的典型用法代码示例。如果您正苦于以下问题:Python get_available_worlds函数的具体用法?Python get_available_worlds怎么用?Python get_available_worlds使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_available_worlds函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:brucepro,项目名称:micropsi2,代码行数:7,代码来源:test_runtime_world_basics.py


示例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))
开发者ID:joschabach,项目名称:micropsi2,代码行数:7,代码来源:micropsi_app.py


示例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)
开发者ID:Doik,项目名称:micropsi2,代码行数:27,代码来源:micropsi_app.py


示例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
开发者ID:brucepro,项目名称:micropsi2,代码行数:9,代码来源:test_runtime_world_basics.py


示例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)
开发者ID:conorshankey,项目名称:micropsi2,代码行数:10,代码来源:micropsi_app.py


示例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)
开发者ID:Doik,项目名称:micropsi2,代码行数:12,代码来源:micropsi_app.py


示例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
开发者ID:pBartels,项目名称:micropsi2,代码行数:12,代码来源:conftest.py


示例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)
开发者ID:brucepro,项目名称:micropsi2,代码行数:21,代码来源:test_runtime_world_basics.py


示例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
开发者ID:brucepro,项目名称:micropsi2,代码行数:13,代码来源:conftest.py


示例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)
开发者ID:joschabach,项目名称:micropsi2,代码行数:15,代码来源:micropsi_app.py


示例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
开发者ID:Doik,项目名称:micropsi2,代码行数:15,代码来源:core_rpc_api.py


示例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
开发者ID:joschabach,项目名称:micropsi2,代码行数:5,代码来源:micropsi_app.py


示例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)
开发者ID:joschabach,项目名称:micropsi2,代码行数:5,代码来源:micropsi_app.py


示例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)
开发者ID:joschabach,项目名称:micropsi2,代码行数:6,代码来源:micropsi_app.py


示例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())
开发者ID:Doik,项目名称:micropsi2,代码行数:6,代码来源:micropsi_app.py


示例16: test_add_worldobject_without_id

def test_add_worldobject_without_id(test_world):
    world = runtime.get_available_worlds()[test_world]
    count = len(world.objects)
    runtime.add_worldobject(test_world, "Default", (10, 10), name='bazbaz', parameters={})
    assert count + 1 == len(world.objects)
    assert count + 1 == len(world.data['objects'])
开发者ID:brucepro,项目名称:micropsi2,代码行数:6,代码来源:test_runtime_world_basics.py



注:本文中的micropsi_core.runtime.get_available_worlds函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python runtime.get_nodenet函数代码示例发布时间:2022-05-27
下一篇:
Python utils.now_in_utc函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap