当前位置: 首页>>代码示例>>Python>>正文


Python DatabaseManager.retrieve_game_ref方法代码示例

本文整理汇总了Python中database.DatabaseManager.retrieve_game_ref方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.retrieve_game_ref方法的具体用法?Python DatabaseManager.retrieve_game_ref怎么用?Python DatabaseManager.retrieve_game_ref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database.DatabaseManager的用法示例。


在下文中一共展示了DatabaseManager.retrieve_game_ref方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: emulation_info_state

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_game_ref [as 别名]
def emulation_info_state(uuid):
    state_info = {}
    state_ref = dbm.retrieve_save_state(uuid=uuid)[0]
    other_save_states = dbm.retrieve_save_state(game_uuid=state_ref['game_uuid'])
    state_extra_files = dbm.retrieve_file_path(save_state_uuid=uuid)
    state_info['record'] = state_ref
    state_info['availableStates'] = filter(lambda s: True if s.get('save_state_source_data') or s.get('rl_starts_data') else False, other_save_states)
    state_info['fileMapping'] = {k: os.path.join('/game_data', v, k.split('/')[-1]) for k, v in map(lambda x: (x['file_path'], x['source_data']),
                                                                                      state_extra_files)} if state_extra_files else None
    state_info['fileInformation'] = {f['file_path']: f for f in state_extra_files}
    #   Save data is singular, and probably LZMA compressed
    if state_ref['save_state_source_data']:
        state_info['stateFileURL'] = os.path.join('/cite_data', state_ref['save_state_source_data'], '{}'.format(state_ref['uuid']))

    #   Save data is multiple and probably run length encoded
    if state_ref['rl_starts_data'] and state_ref['rl_lengths_data']:
        state_info['rlStartsURL'] = os.path.join('/cite_data', state_ref['rl_starts_data'], '{}'.format(state_ref['uuid']))
        state_info['rlLengthsURL'] = os.path.join('/cite_data', state_ref['rl_lengths_data'], '{}'.format(state_ref['uuid']))

    if state_extra_files:
        main_exec = dbm.retrieve_file_path(save_state_uuid=uuid, main_executable=True)[0]
        state_info['gameFileURL'] = os.path.join('/game_data', main_exec['source_data'], main_exec['file_path'].split('/')[-1])
    else:
        game_ref = dbm.retrieve_game_ref(state_ref['game_uuid'])
        state_info['gameFileURL'] = os.path.join('/game_data', game_ref['source_data'], game_ref['data_image_source'])
    return jsonify(state_info)
开发者ID:gamecip,项目名称:citetool-editor,代码行数:28,代码来源:app.py

示例2: citation_page

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_game_ref [as 别名]
def citation_page(uuid):
    game_ref = dbm.retrieve_game_ref(uuid)
    perf_ref = dbm.retrieve_perf_ref(uuid)
    derived_performances = dbm.retrieve_derived_performances(uuid)
    previous_performances = dbm.retrieve_performance_chain(uuid)[:-1]
    save_states = dbm.retrieve_save_state(game_uuid=uuid)
    extra_files = dbm.retrieve_file_path(game_uuid=uuid)

    if game_ref:
        return render_template('citation.html',
                               citeref=game_ref,
                               is_game=True,
                               is_performance=False,
                               derived_performances=derived_performances,
                               extra_files=extra_files,
                               save_states=save_states)
    elif perf_ref:
        performance_video = "/cite_data/{}/{}".format(perf_ref['replay_source_file_ref'],
                                                      perf_ref['replay_source_file_name'])
        return render_template('citation.html',
                               citeref=perf_ref,
                               is_game=False,
                               is_performance=True,
                               previous_performances=previous_performances,
                               performance_video=performance_video)
    return "No record found, sorry."
开发者ID:gamecip,项目名称:citetool-editor,代码行数:28,代码来源:app.py

示例3: make_performance_package

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_game_ref [as 别名]
 def make_performance_package(performance):
     pack = {}
     game = dbm.retrieve_game_ref(performance['game_uuid'])
     pack['game'] = game.elements if game else None
     pack['performance'] = performance.elements
     #   Last performance is current performance
     pack['previous_performances'] = [i.elements for i in dbm.retrieve_performance_chain(performance['uuid'])[:-1]]
     return pack
开发者ID:gamecip,项目名称:citetool-editor,代码行数:10,代码来源:citetool_editor.py

示例4: play_page

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_game_ref [as 别名]
def play_page(uuid):
    init_state = request.values.get('init_state')
    cite_ref = dbm.retrieve_game_ref(uuid)
    state_dicts = dbm.retrieve_save_state(game_uuid=uuid)

    if init_state:
        init_state = dbm.retrieve_save_state(uuid=init_state)[0]
        has_exec = dbm.retrieve_file_path(save_state_uuid=init_state['uuid'], main_executable=True)
    else:
        has_exec = dbm.retrieve_file_path(game_uuid=uuid, save_state_uuid=None, main_executable=True)
        init_state = {'uuid': 'NO_ID'}

    if cite_ref and (cite_ref['data_image_source'] or has_exec):
        return render_template('play.html',
                               init_state=init_state,
                               cite_ref=cite_ref)
    return "No game data source found, sorry!"
开发者ID:gamecip,项目名称:citetool-editor,代码行数:19,代码来源:app.py

示例5: emulation_info_game

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_game_ref [as 别名]
def emulation_info_game(uuid):
    game_info = {}
    game_ref = dbm.retrieve_game_ref(uuid)
    game_extra_files = dbm.retrieve_file_path(game_uuid=uuid, save_state_uuid=None)

    if game_ref and (game_ref['data_image_source'] or game_extra_files):
        gis = game_ref['data_image_source']
        gsd = game_ref['source_data']
        main_exec = dbm.retrieve_file_path(game_uuid=uuid, save_state_uuid=None, main_executable=True)
        main_fp = main_exec[0]['file_path'].split('/')[-1] if main_exec else None
        game_info['gameFileURL'] = os.path.join('/game_data', gsd, gis) if gis else main_fp
        if game_extra_files:
            game_info['fileMapping'] = {k: os.path.join('/game_data', v, k.split('/')[-1]) for k, v in map(lambda x: (x['file_path'], x['source_data']),
                                                                                     game_extra_files)}
            game_info['fileInformation'] = {f['file_path']: f for f in game_extra_files}
        game_info['stateFileURL'] = None
        game_info['record'] = game_ref.elements
        game_info['availableStates'] = filter(lambda s: True if s.get('save_state_source_data') or s.get('rl_starts_data') else False, dbm.retrieve_save_state(game_uuid=uuid))
        game_info['availablePerformances'] = [dict(p.get_element_items()) for p in dbm.retrieve_derived_performances(uuid)]
    return jsonify(game_info)
开发者ID:gamecip,项目名称:citetool-editor,代码行数:22,代码来源:app.py

示例6: game_update

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_game_ref [as 别名]
def game_update(uuid):
    update_fields = json.loads(request.form.get('update_fields'))
    dbm.update_table(dbm.GAME_CITATION_TABLE, update_fields.keys(), update_fields.values(), ["uuid"], [uuid])
    game_ref = dbm.retrieve_game_ref(uuid)
    #dbm.update_table(dbm.FTS_INDEX_TABLE, ['content'], [game_ref.to_json_string()], ["uuid"], [uuid])
    return game_ref.to_json_string()
开发者ID:gamecip,项目名称:citetool-editor,代码行数:8,代码来源:app.py

示例7: delete

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import retrieve_game_ref [as 别名]
def delete(ctx, uuid, keep_performances):
    no_prompts = ctx.obj['NO_PROMPTS']
    verbose = ctx.obj['VERBOSE']

    def check_delete(path):
        try:
            shutil.rmtree(path)
        except OSError as e:
            print e.message

    def delete_from_fts(uuid):
        ix = open_dir(LOCAL_FTS_INDEX)
        writer = ix.writer()
        writer.delete_by_term('id', uuid)
        writer.commit()

    game_ref = dbm.retrieve_game_ref(uuid)
    perf_ref = dbm.retrieve_perf_ref(uuid)
    state_ref = dbm.retrieve_save_state(uuid=uuid)
    if game_ref:
        perfs = dbm.retrieve_derived_performances(uuid)
        states = dbm.retrieve_save_state(game_uuid=uuid)
        files = dbm.retrieve_file_path(game_uuid=uuid)

        for f in files:
                check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_GAME_DATA_STORE, f['source_data']))
        dbm.delete_from_table(dbm.GAME_FILE_PATH_TABLE, ['game_uuid'], [uuid])

        for s in states:
            if s['save_state_source_data']:
                check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, s['save_state_source_data']))
            else:
                if s['rl_starts_data']:
                    check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, s['rl_starts_data']))
                    check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, s['rl_lengths_data']))
            if s['has_screen']:
                check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, s['uuid']))
        dbm.delete_from_table(dbm.GAME_SAVE_TABLE, ['game_uuid'], [uuid])

        for p in perfs:
            if p['replay_source_file_ref']:
                check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, p['replay_source_file_ref']))
            dbm.delete_from_table(dbm.SAVE_STATE_PERFORMANCE_LINK_TABLE,['performance_uuid'], [p['uuid']])
        dbm.delete_from_table(dbm.PERFORMANCE_CITATION_TABLE, ['game_uuid'], [uuid])

        if game_ref['source_data']:
            check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_GAME_DATA_STORE, game_ref['source_data']))

        dbm.delete_from_table(dbm.GAME_CITATION_TABLE, ['uuid'], [uuid])
        delete_from_fts(uuid)
    elif perf_ref:
        dbm.delete_from_table(dbm.SAVE_STATE_PERFORMANCE_LINK_TABLE,['performance_uuid'], [uuid])
        if perf_ref['replay_source_file_ref']:
            check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, perf_ref['replay_source_file_ref']))
        dbm.delete_from_table(dbm.PERFORMANCE_CITATION_TABLE, ['uuid'], [uuid])
        delete_from_fts(uuid)
    elif state_ref:
        state_ref = state_ref[0] # retrieve states returns lists
        files = dbm.retrieve_file_path(save_state_uuid=uuid)
        for f in files:
            check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_GAME_DATA_STORE, f['source_data']))
        dbm.delete_from_table(dbm.SAVE_STATE_PERFORMANCE_LINK_TABLE,['save_state_uuid'], [uuid])
        if state_ref['has_screen']:
            check_delete(os.path.join(LOCAL_DATA_ROOT, LOCAL_CITATION_DATA_STORE, state_ref['uuid']))
        dbm.delete_from_table(dbm.GAME_SAVE_TABLE, ['uuid'], [uuid])
        delete_from_fts(uuid)
    else:
        click.echo('UUID {} not found.'.format(uuid))
        sys.exit(1)
开发者ID:gamecip,项目名称:citetool-editor,代码行数:71,代码来源:citetool_editor.py


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