示例#1
0
def test_database_double_arg(arg):
    # Test the database where there are two command line parameters.
    # The first parameter is the name of the method to test.
    # The second parameter is the input parameter for the method that is being test.
    arg1 = arg[1].lower()
    arg2 = arg[2].lower()
    db = Database()
    if arg1 == "__contains__":
        print(arg2 in db)
    elif arg1 == "pokemon_id_exists":
        print(db.pokemon_id_exists(arg2))
    elif arg1 == "pokemon_name_exists":
        print(db.pokemon_name_exists(arg2))
    elif arg1 == "get_pokemon":
        print(db.get_pokemon(arg2))
    elif arg1 == "get_pokemon_by_name":
        print(db.get_pokemon_by_name(arg2))
    elif arg1 == "get_pokemon_by_id":
        print(db.get_pokemon_by_id(arg2))
    elif arg1 == "names_with_prefix":
        print_items(db.names_with_prefix(arg2))
    elif arg1 == "names_with_infix":
        print_items(db.names_with_infix(arg2))
    elif arg1 == "get_light":
        print_items(db.get_light(threshold=int(arg2) / 10, all_pkmn=True))
    elif arg1 == "get_dark":
        print_items(db.get_dark(threshold=int(arg2) / 10, all_pkmn=True))
    else:
        print("No such public method '" + arg + "' with two parameters"
              " exists in the Database class.")
示例#2
0
def party_get_pokemon():
    file = open(party_file, 'r')
    lines = file.read().splitlines()
    db = Database()
    pokemon = []
    for line in lines:
        if db.pokemon_name_exists(line):
            pokemon.append(line)
    file.close()
    return pokemon