Ejemplo n.º 1
0
def main(json_file):
    sets_dict = read_id_to_terms(json_file)

    load_items_db_from_dump()
    for ankama_id, set_data in sets_dict.iteritems():
        set_name = set_data.get('name')
        print set_name
        if set_name:
            conn = sqlite3.connect(get_items_db_path())
            c = conn.cursor()
            c.execute('SELECT id FROM %s WHERE name = ?' % 'sets',
                      (set_name, ))
            query_result = c.fetchone()
            conn.close()
            if query_result is not None:
                store_set_data(query_result[0], ankama_id, set_data)
            else:
                filetomod = open('MissingSets.txt', 'a')

                name_to_print = set_name + '\n'
                filetomod.write(name_to_print.encode('utf-8'))

                filetomod.close()
    save_items_db_to_dump()
    invalidate_structure()
Ejemplo n.º 2
0
def main(json_file, names_table, entities_table):
    id_to_terms_in_lang, en_name_to_ankama_id_and_type = read_id_to_terms(json_file, entities_table)
    ankama_profile_to_all_dict, en_to_all_dict = convert_to_dicts(id_to_terms_in_lang)
    
    load_items_db_from_dump()
    conn = sqlite3.connect(get_items_db_path())
    c = conn.cursor()
    
    for ankama_profile, other_langs in ankama_profile_to_all_dict.iteritems():
        ankama_id, _ = ankama_profile
        if len(other_langs) != len(NON_EN_LANGUAGES):
            print ('WARNING: item with ankama_id %d missing languages: %s'
                   % (ankama_id, str(other_langs)))
        item_id, _ = get_item_id_and_name_for_ankama_profile(c, entities_table, ankama_profile)
        if item_id is not None:
            store_item_translations(c, names_table, item_id, other_langs)

    for en_term, other_langs in en_to_all_dict.iteritems():
        if len(other_langs) != len(NON_EN_LANGUAGES):
            print 'WARNING: %s missing languages: %s' % (en_term, str(other_langs))
        c.execute('SELECT id, ankama_id FROM %s WHERE name = ?' % entities_table, (en_term,))
        query_result = c.fetchone()
        if query_result is not None:
            ankama_id = query_result[1]
            if ankama_id is None:
                print 'ankama_id of %s is None, using en name to update' % en_term
                item_id = query_result[0]
                store_item_translations(c, names_table, item_id, other_langs)
                ankama_id, ankama_type = en_name_to_ankama_id_and_type[en_term]
                c.execute('UPDATE %s SET ankama_id = ?, ankama_type = ? WHERE ID = ?' % entities_table,
                          (ankama_id, ankama_type, item_id))
        
    conn.commit()
    conn.close()
    save_items_db_to_dump()
Ejemplo n.º 3
0
def main(json_file):
    weapons = read_id_to_terms(json_file)

    load_items_db_from_dump()
    for ankama_id, weapon_data in weapons.iteritems():
        ankama_profile = (ankama_id, 'mounts')
        conn = sqlite3.connect(get_items_db_path())
        c = conn.cursor()
        item_id, weapon_name = get_item_id_and_name_for_ankama_profile(
            c, 'items', ankama_profile, True)
        conn.close()
        #print item_id
        store_weapon_data(item_id, weapon_name, weapon_data)

    save_items_db_to_dump()
Ejemplo n.º 4
0
def main(json_file):
    weapons = read_id_to_terms(json_file)
    
    load_items_db_from_dump()
    for weapon in weapons:
        ankama_profile = (weapon['ankama_id'], 'equipment')
        
        conn = sqlite3.connect(get_items_db_path())
        c = conn.cursor()
        item_id, weapon_name = get_item_id_and_name_for_ankama_profile(c, 'items', ankama_profile)
        conn.close()
        #print item_id
        if item_id is not None:
            store_weapon_data(item_id, weapon_name, weapon)

    save_items_db_to_dump()
Ejemplo n.º 5
0
def main(json_file):
    weapons = read_id_to_terms(json_file)

    load_items_db_from_dump()

    f = open("missing.txt", "w+")
    f.write("[")
    for ankama_id in weapons:
        print 'Checking %d %s' % (ankama_id, weapons[ankama_id])
        ankama_profile = (ankama_id, 'equipment')
        conn = sqlite3.connect(get_items_db_path())
        c = conn.cursor()
        item_id, weapon_name = get_item_id_and_name_for_ankama_profile(
            c, 'items', ankama_profile)
        conn.close()

        if not (item_id and weapon_name):
            f.write('{"ankama_id": %d, "name": "%s"},\n' %
                    (ankama_id, weapons[ankama_id]))
    f.close()