def update_game(query, update_query, connection=None, verbose=False): new_query = {} game = find_game(query, connection) choice = "a" for field in update_query: if game is None or ( field in game and game[field] != update_query[field] and update_query[field] is not None) or (field not in game): if verbose: while (choice not in "yYnN"): if update_query[field] == str: choice = raw_input( "%s: Replace %s by %s? [Y/n]" % ((field + str(game["_id"]), normalize( game[field]), normalize(update_query[field])))) else: choice = 'Y' if choice == 'y' or choice == 'Y': new_query[field] = update_query[field] elif choice == 'n' or choice == 'N': continue else: new_query[field] = update_query[field] if len(new_query) > 0: return update(query, new_query, "prono", "games", connection) else: return None
def update_team(query, update_query, connection=None): return update(query, update_query, "prono", "teams", connection)
def update_people(query, update_query): return update(query, update_query, "prono", "peoples")
def update_stadium(query, update_query, connection=None): return update(query, update_query, "prono", "stadiums", connection)
def update_region(query, update_query): return update(query, update_query, "prono", "regions")