From d71790fff63183abcba6b45a10849e3eef1bab44 Mon Sep 17 00:00:00 2001 From: Vincent Zeng Date: Fri, 23 Feb 2018 15:28:25 -0500 Subject: [PATCH] fixed raw_input error for python 3 --- ttbp/ttbp.py | 31 ++++++++++++++++--------------- ttbp/util.py | 7 ++++--- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ttbp/ttbp.py b/ttbp/ttbp.py index 253e52b..971902b 100644 --- a/ttbp/ttbp.py +++ b/ttbp/ttbp.py @@ -40,6 +40,7 @@ import time import json from email.mime.text import MIMEText import datetime +from six.moves import input import inflect @@ -233,7 +234,7 @@ def check_init(): setup_repair() else: - raw_input("press to explore your feels.\n\n") + input("press to explore your feels.\n\n") core.load(SETTINGS) @@ -246,7 +247,7 @@ def init(): """ try: - raw_input(""" + input(""" i don't recognize you, stranger. let's make friends. press to begin, or to get out of here.""") @@ -296,7 +297,7 @@ press to begin, or to get out of here.""") setup() core.load(SETTINGS) - raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit to continue.\n\n") + input("\nyou're all good to go, "+chatter.say("friend")+"! hit to continue.\n\n") return "" def gen_header(): @@ -396,7 +397,7 @@ def setup_repair(): print("...") time.sleep(1) - raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit to continue.\n\n") + input("\nyou're all good to go, "+chatter.say("friend")+"! hit to continue.\n\n") def setup(): ''' @@ -420,7 +421,7 @@ def setup(): util.print_menu(menuOptions, SETTINGS.get("rainbows", False)) try: - choice = raw_input("\npick a setting to change (or type 'q' to exit): ") + choice = input("\npick a setting to change (or type 'q' to exit): ") except KeyboardInterrupt: redraw(EJECT) return SETTINGS @@ -475,7 +476,7 @@ def setup(): save_settings() return setup() - raw_input("\nyou're all good to go, {friend}! hit to continue.\n\n".format(friend=chatter.say("friend"))) + input("\nyou're all good to go, {friend}! hit to continue.\n\n".format(friend=chatter.say("friend"))) redraw() return SETTINGS @@ -511,7 +512,7 @@ def main_menu(): util.print_menu(menuOptions, SETTINGS.get("rainbows", False)) try: - choice = raw_input("\ntell me about your feels (or type 'q' to exit): ") + choice = input("\ntell me about your feels (or type 'q' to exit): ") except KeyboardInterrupt: redraw(EJECT) return main_menu() @@ -571,12 +572,12 @@ def feedback_menu(): ''' util.print_menu(SUBJECTS, SETTINGS.get("rainbows", False)) - choice = raw_input("\npick a category for your feedback: ") + choice = input("\npick a category for your feedback: ") cat = "" if choice in ['0', '1', '2', '3']: cat = SUBJECTS[int(choice)] - entered = raw_input(""" + entered = input(""" composing a {mail_category} to ~endorphant. press to open an external text editor. mail will be sent once you save and quit. @@ -751,7 +752,7 @@ i'd love to hear about your ideas and brainstorm about new features! thanks to everyone who reads, listens, writes, and feels.\ """) - raw_input("\n\npress to go back home.\n\n") + input("\n\npress to go back home.\n\n") redraw() return @@ -763,7 +764,7 @@ def write_entry(entry=os.path.join(config.USER_DATA, "test.txt")): main feels-recording handler ''' - entered = raw_input(""" + entered = input(""" feels will be recorded for today, {today}. if you've already started recording feels for this day, you @@ -972,7 +973,7 @@ wall will be recorded if you save the file, and you can cancel your changes by exiting without saving. """) - raw_input("press to visit the wall\n\n") + input("press to visit the wall\n\n") subprocess.call([SETTINGS.get("editor"), config.WALL]) subprocess.call(["rm", config.WALL_LOCK]) redraw("thanks for visiting the graffiti wall!") @@ -1033,13 +1034,13 @@ def select_publish_dir(): print("\ncurrent publish dir:\t"+os.path.join(config.PUBLIC, SETTINGS["publish dir"])) republish = True - choice = raw_input("\nwhere do you want your blog published? (leave blank to use default \"blog\") ") + choice = input("\nwhere do you want your blog published? (leave blank to use default \"blog\") ") if not choice: choice = "blog" publishDir = os.path.join(config.PUBLIC, choice) while os.path.exists(publishDir): - second = raw_input("\n"+publishDir+"""\ + second = input("\n"+publishDir+"""\ already exists! setting this as your publishing directory means this program may @@ -1278,7 +1279,7 @@ something strange happened to you during this update. confirm = "" while confirm not in ("x", "", "X", ""): - confirm = raw_input("\nplease type when you've finished reading about the updates! ") + confirm = input("\nplease type when you've finished reading about the updates! ") open(versionFile, "w").write(__version__) diff --git a/ttbp/util.py b/ttbp/util.py index 85707b5..5168018 100644 --- a/ttbp/util.py +++ b/ttbp/util.py @@ -25,6 +25,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import random import time +from six.moves import input import colorama import inflect @@ -179,7 +180,7 @@ def list_select(options, prompt): ans = "" invalid = True - choice = raw_input("\n"+prompt) + choice = input("\n"+prompt) if choice in BACKS: return False @@ -205,11 +206,11 @@ def input_yn(query): ''' try: - ans = raw_input(query+" [y/n] ") + ans = input(query+" [y/n] ") except KeyboardInterrupt: input_yn(query) while ans not in ["y", "n"]: - ans = raw_input("'y' or 'n' please: ") + ans = input("'y' or 'n' please: ") return ans == "y"