def delete_prof(profname: str) -> None: """Function that deletes the selected profile. Profile name must be checked before. :param profname: Name of the gitcher profile to operate with :type profname: [str] :return: None """ model_layer.delete_profile(profname) print(MSG_OK + " Profile {0} deleted.".format(profname))
def update_prof() -> None: """Function that updates a profile on interactive mode. Profile name have not to be checked before. :return: None """ print("\nLets go to update a gitcher profile...") old_profname = listen("Enter the profile name: ", dictionary.profs_profnames) while not check_profile(old_profname): print(MSG_ERROR + " {0} not exists. Change name...".format(old_profname)) old_profname = listen("Enter profile name: ", dictionary.profs_profnames) prof = model_layer.recuperate_prof(old_profname) profname = old_profname if yes_or_no("Do you want to update the profile name?"): profname = listen("Enter the new profile name: ") name = prof.name if yes_or_no("Do you want to update the user name?"): name = listen("Enter the new name: ") email = prof.email if yes_or_no("Do you want to update the user email?"): email = listen("Enter the new email: ") while not validate_email(email): print(MSG_ERROR + " Invalid email format. Try again...".format(email)) email = listen("Enter the new email: ") if yes_or_no("Do you want to update the PGP sign config?"): if yes_or_no("Do you want to use a PGP sign key?"): signkey = listen("Enter the git user signkey: ") signpref = yes_or_no("Do you want to autosign every commit?") else: signkey = None signpref = False else: signkey = prof.signkey signpref = prof.signpref # Remove the old profile model_layer.delete_profile(old_profname) # And save the new... prof = model_layer.Prof(profname, name, email, signkey, signpref) model_layer.save_profile(prof) print(MSG_OK + " Profile {0} updated.".format(profname))