def load_user_data(path): for user in iter_csv_table(path, 'user'): #print 'load user %s'%(user,) turn = int(user['turn']) store_user = store.get_user(user['user_id']) if store_user and 'turn' in store_user: store_user_turn = store_user['turn'] if store_user_turn and int(store_user_turn) >= turn: print 'User %s already exist in db, actual db turn info %s'%(store_user['name'], store_user_turn) continue store.add_user(user) # no need to make it on this level, as there should be only one user store.clear_user_data(user['user_id']) load_csv_table(path, 'open_planet') load_csv_table(path, 'race') load_csv_table(path, 'diplomacy') load_csv_table(path, 'hw') load_csv_table(path, 'flying_fleet') load_csv_table(path, 'alien_flying_fleet') load_csv_table(path, 'user_planet') load_csv_table(path, 'fleet') load_csv_table(path, 'proto') load_csv_table(path, 'proto_action') load_csv_table(path, 'fleet_unit') load_csv_table(path, 'garrison_unit') load_csv_table(path, 'garrison_queue_unit') load_csv_table(path, 'unit') load_csv_table(path, 'proto_action') load_csv_table(path, 'action') store.normalize_user_fleets(user['user_id'])
def test_load_save(self): user_id = 3 user_data = {'user_id':user_id, 'race_id':22, 'name':u'test_user', 'turn':33} store.add_user(user_data) save_user_data(user_id, '/tmp/test')