def add_location(pokem): edition = input('Welche Edition? > ') location = input('Welche Location? > ') pkms = create_list(pokem) invalidpk = 0 for pokemon in pkms: if not pkdao.valid_pk(pokemon): print("Ungueltiges Pokemon '{0}'".format(pokemon)) invalidpk += 1 else: pkdao.add_loc(pokemon, edition, location) print_pokemon(pokemon) if invalidpk < len(pkms): moreinput = input("Moechten Sie mehr Daten einpflegen? yes/N > ") moreinput = moreinput.lower() while moreinput == 'yes' or moreinput == 'y': edition = input('Welche Edition? > ') loc = input('Welche Location? > ') for pokemon in pkms: if not pkdao.valid_pk(pokemon): print("Ungueltiges Pokemon '{0}'".format(pokemon)) else: pkdao.add_loc(pokemon, edition, loc) print_pokemon(pokemon) moreinput = input("Moechten Sie mehr Daten einpflegen? yes/N > ") moreinput = moreinput.lower()
def create_list(pks): pkms = [] if re.match('[\w]+[-][\w]+', pks) != None: start, end = pks.split('-') if re.match('[0-9]+[-][0-9]+', pks) != None: pkms = range(int(start), int(end)+1) else: if not pkdao.valid_pk(start): print("Ungueltiges Pokemon '{0}'".format(start)) elif not pkdao.valid_pk(start): print("Ungueltiges Pokemon '{0}'".format(end)) else: start = pkdao.get_pknr(start) end = pkdao.get_pknr(end) pkms = range(int(start), int(end)+1) elif ',' in pks: pkms = pks.split(',') for i in range (0, len(pkms)): pk = pkms[i] pk = pk.strip() pk = pk.capitalize() pkms[i] = pk elif re.match('[0-9]+', pks) != None: pkms.append(pks) else: pkms = pkdao.get_pk_list_by_namesnippet(pks) return pkms
def rm_info(pokem): pkms = create_list(pokem) for pokemon in pkms: if not pkdao.valid_pk(pokemon): print("Ungueltiges Pokemon '{0}'".format(pokemon)) else: pkdao.rm_info(pokemon) print_pokemon(pokemon)
def set_info(pokem): info = input('Info? > ') pkms = create_list(pokem) for pokemon in pkms: if not pkdao.valid_pk(pokemon): print("Ungueltiges Pokemon '{0}'".format(pokemon)) else: pkdao.set_info(pokemon, info) print_pokemon(pokemon)
def set_c(pokem, catched): if catched == 1: print('Herzlichen Glueckwunsch zum Fangerfolg! :)') pkms = create_list(pokem) for pokemon in pkms: if not pkdao.valid_pk(pokemon): print("Ungueltiges Pokemon '{0}'".format(pokemon)) else: pkdao.set_c(pokemon, catched) print_pokemon(pokemon)
def print_pokemon(pokem): if isinstance(pokem, str): pkms = create_list(pokem) if len(pkms) == 0 : print("Ungueltiges Pokemon '{0}'".format(pokem)) return for pokemon in pkms: if not pkdao.valid_pk(pokemon): print("Ungueltiges Pokemon '{0}'".format(pokemon)) else: print_output(pokemon) #Ist das Pokemon ein int-Wert, wurde es im vorherigen Programmverlauf bereits auf Gueltigkeit geprueft. elif isinstance(pokem, int): print_output(pokem)
def rm_location(pokem): pkms = create_list(pokem) invalidpk = 0 for pokemon in pkms: if not pkdao.valid_pk(pokemon): print("Ungueltiges Pokemon '{0}'".format(pokemon)) invalidpk += 1 else: if pkdao.get_number_of_locs(pokemon) == 0: print("Fuer Pokemon '{0}' existieren keine Locationangaben".format(pokemon)) invalidpk += 1 else: print_pokemon(pokemon) if invalidpk < len(pkms): rmall = input('Sollen alle Eintraege geloescht werden? yes/N > ') rmall = rmall.lower() if rmall == 'yes' or rmall == 'y': for pokemon in pkms: pkdao.rm_all_loc(pokemon) print_pokemon(pokemon) else: print('Spezifizieren Sie bitte den Eintrag der geloescht werden soll.') edition = input('Loeschen: Welche Edition? > ') location = input('Loeschen: Welche Location? > ') for pokemon in pkms: pkdao.rm_loc(pokemon, edition, location) print_pokemon(pokemon) morerm = input("Moechten Sie mehr Daten loeschen? yes/N > ") morerm = morerm.lower() while morerm == 'yes' or morerm == 'y': edition = input('Loeschen: Welche Edition? > ') location = input('Loeschen: Welche Location? > ') for pokemon in pkms: pkdao.rm_loc(pokemon, edition, location) print_pokemon(pokemon) morerm = input("Moechten Sie mehr Daten loeschen? yes/N > ") morerm = morerm.lower()