diff --git a/json_generator/main.py b/json_generator/main.py index 6cdee9d..da0bd40 100644 --- a/json_generator/main.py +++ b/json_generator/main.py @@ -25,12 +25,19 @@ def modify_variable(var, vars): response = input("Select a property to modify for %s or q to exit property modifying: " %(var.name)) if response == "type": - response = input("Enter the type of variable this is (currently %s): " %(var.type)) + response = input("Enter the type of variable this is (currently %s) or c to cancel: " %(var.type)) + + if response == "c" or response == "C": + continue + vars[var.name].type = response print("Updated to %s." %(response)) elif response == "start": - response = input("Enter the variable's starting point (currently %f): " %(var.starting_point)) + response = input("Enter the variable's starting point (currently %f) or c to cancel: " %(var.starting_point)) + + if response == "c" or response == "C": + continue try: vars[var.name].starting_point = float(response) @@ -39,15 +46,10 @@ def modify_variable(var, vars): print("The starting point must be a number.") elif response == "end": - response = input("Enter the variable's ending point (currently %f): " %(var.ending_point)) - - try: - vars[var.name].ending_point = float(response) - print("Updated to %f." %(float(response))) - except ValueError: - print("The ending point must be a number.") - - pass + response = input("Enter the variable's ending point (currently %f) or c to cancel: " %(var.ending_point)) + + if response == "c" or response == "C": + continue elif response == "q": return diff --git a/main.py b/main.py index 53cf367..25993ee 100755 --- a/main.py +++ b/main.py @@ -31,12 +31,19 @@ def modify_variable(var, vars): response = input("Select a property to modify for %s or q to exit property modifying: " %(var.name)) if response == "type": - response = input("Enter the type of variable this is (currently %s): " %(var.type)) + response = input("Enter the type of variable this is (currently %s) or c to cancel: " %(var.type)) + + if response == "c" or response == "C": + continue + vars[var.name].type = response print("Updated to %s." %(response)) elif response == "start": - response = input("Enter the variable's starting point (currently %f): " %(var.starting_point)) + response = input("Enter the variable's starting point (currently %f) or c to cancel: " %(var.starting_point)) + + if response == "c" or response == "C": + continue try: vars[var.name].starting_point = float(response) @@ -45,8 +52,11 @@ def modify_variable(var, vars): print("The starting point must be a number.") elif response == "end": - response = input("Enter the variable's ending point (currently %f): " %(var.ending_point)) - + response = input("Enter the variable's ending point (currently %f) or c to cancel: " %(var.ending_point)) + + if response == "c" or response == "C": + continue + try: vars[var.name].ending_point = float(response) print("Updated to %f." %(float(response)))