def show_prompt(verchk, pause=True): """Shows the standard prompt for handling version numbers in a project.""" import qprompt verchk.run() if qprompt.ask_yesno("Update version?", dft="n"): newver = qprompt.ask_str("New version string") if newver: verchk.update(newver) verchk.run() if pause: qprompt.pause()
def run_command(self, menu_context): """Run the command that will add the new word to the dictionary. :menu_context: The context of the menu. """ dictionary = menu_context.get("dictionary", None) if dictionary is None: print("Menu does not have a dictionary") qprompt.pause() return number_of_questions = safe_ask.safe_ask( qprompt.ask_int, "Insert the number of questions per known level", test.Test.DEFAULT_NUMBER_OF_QUESTIONS, vld=lambda x: x > 0) current_test = test.Test(dictionary, number_of_questions) current_test.run() qprompt.pause()
def delPass(): global pragma_input conn = sqlcipher.connect('.passman.db') cur = conn.cursor() cur.execute(pragma_input) print(pd.read_sql_query("SELECT * FROM passwords", conn)) print("Select the ID of the credentials you wish to DELETE.") selection = qprompt.ask_int("ID") confirm = qprompt.ask_yesno(default="y") if confirm == False: print("Credential removal has been CANCELLED!") print() retry = qprompt.ask_yesno("Retry?", default="y") if retry == True: delPass() else: mainMenu() else: cur.execute("DELETE FROM passwords WHERE ID = '{}'".format(selection)) print("Credentials deleted successfully!") conn.commit() cur.close() qprompt.pause() mainMenu()
def run_command(self, menu_context): """Run the command that will add load the file to the dict. :menu_context: The context of the menu to add the dictionary to. :Note: This functions adds the new words to the dictionary. """ # Get the dictionary (and validate it exists). dictionary = menu_context.get("dictionary", None) if dictionary is None: print("Menu does not have a dictionary") qprompt.pause() return # Get the name of the yaml file. file_with_words = safe_ask.safe_ask( qprompt.ask_str, "Insert the name of the file with the words") # Add the new word. self.add_new_words(dictionary, file_with_words) # Make sure the user sees the output before ending the action. qprompt.pause()
"""This example deletes all PYC files in the project.""" import auxly import qprompt delfunc = lambda is_test: auxly.filesys.delete("..", "\.pyc$", recurse=True, test=is_test) delfiles = delfunc(True) if len(delfiles): print("Files to delete:") print("\n".join([" " + i for i in delfiles])) if qprompt.ask_yesno("OK to delete?"): if delfunc(False) == delfiles: qprompt.alert("Files deleted.") else: qprompt.warn("Some files not deleted!") else: qprompt.alert("No files to delete.") qprompt.pause()
import qprompt name = qprompt.ask_str("Name", blk=False) age = qprompt.ask_int("Age", vld=range(130)) if qprompt.ask_yesno("Say hello?", dft="y"): print("Hi %s! You are %u years old!" % (name, age)) qprompt.pause()