Example #1
0
def citations_all_page():
    all_game_cites = [dbm.create_cite_ref_from_db(GAME_CITE_REF, x) for x in dbm.retrieve_all_from_table(dbm.GAME_CITATION_TABLE)]
    all_perf_cites = [dbm.create_cite_ref_from_db(PERF_CITE_REF, x) for x in dbm.retrieve_all_from_table(dbm.PERFORMANCE_CITATION_TABLE)]
    return render_template('citations_main.html',
                           all_game_cites=all_game_cites,
                           all_perf_cites=all_perf_cites,
                           perf_headers=all_perf_cites[0].get_element_names() if all_perf_cites else [],
                           game_headers=all_game_cites[0].get_element_names() if all_game_cites else [])
 def process_citation_url():
     while True:
         url = (yield)
         if not dbm.is_attr_in_db('source_url', url, dbm.GAME_CITATION_TABLE):
             click.echo('Extracting url {} through coroutine.'.format(url))
             extractor = get_extractor_for_uri(url, get_url_source(url))
             extractor.extract()
             citation, extracted_options = extractor.create_citation()
             citations.append((citation, NEW))
         else:
             click.echo('Found {} in local db.'.format(url))
             citation = dbm.create_cite_ref_from_db(GAME_CITE_REF,
                                                    dbm.retrieve_attr_from_db(
                                                        'source_url',
                                                        url,
                                                        dbm.GAME_CITATION_TABLE)[0])
             citations.append((citation, OLD))
    def get_cite_for_uuid(result):
        ref_type = result['tags']
        uuid = result['uuid']
        if ref_type == GAME_CITE_REF:
            table = dbm.GAME_CITATION_TABLE
        if ref_type == PERF_CITE_REF:
            table = dbm.PERFORMANCE_CITATION_TABLE
        if ref_type == STATE_CITE_REF:
            table = dbm.GAME_SAVE_TABLE

        if ref_type in (GAME_CITE_REF, PERF_CITE_REF):
            db_values = dbm.retrieve_attr_from_db('uuid', uuid, table, limit=1)[0]
            citation = dbm.create_cite_ref_from_db(ref_type, db_values)
        else:
            citation = dbm.retrieve_save_state(uuid=uuid)[0]
            citation['ref_type'] = STATE_CITE_REF
        return citation