From 7c6ce6554b8a96ede6f5f5bb1f133ac07137b41c Mon Sep 17 00:00:00 2001 From: Vincent Zeng Date: Thu, 15 Mar 2018 16:17:21 -0400 Subject: [PATCH] stubbing out deletion feature --- ttbp/ttbp.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++- ttbp/util.py | 2 +- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/ttbp/ttbp.py b/ttbp/ttbp.py index 8247789..dff3a1f 100644 --- a/ttbp/ttbp.py +++ b/ttbp/ttbp.py @@ -645,7 +645,11 @@ def review_menu(intro=""): else: top = nofeels elif choice == 3: - top = DUST + if hasfeels: + redraw("deleting feels") + delete_feels() + else: + top = nofeels elif choice == 4: if hasfeels: redraw("!!!PURGING ALL FEELS!!!") @@ -811,6 +815,58 @@ figure it out!""") return +def delete_feels(): + """handles deleting feels one at a time""" + + feel = input("""which day's feels do you want to load for deletion? + +YYYYMMDD: """) + + if feel in util.BACKS: + return + + print("...") + time.sleep(1) + print("""\ +here's a preview of that feel. press when you're done reviewing! +-------------------------------------------------------------""") + + if subprocess.call(["less", os.path.join(config.USER_DATA, feel+".txt")]): + redraw("deleting feels") + print("""\ +sorry, i couldn't find feels for {date}! + +please try again, or type to cancel.""".format(date=feel)) + return delete_feels() + + print(""" +------------------------------------------------------------- + +feels deletion is irreversible! if you're sure you want to delete this feel, +type the date again to confirm, or q to cancel.""") + + confirm = input("[{feeldate}]> ".format(feeldate=feel)) + + if confirm == feel: + print("...") + time.sleep(1) + print("feels deleted!") + else: + print("deletion canceled!") + + ans = util.input_yn("""do you want to delete a different feel? +please enter""") + + if ans: + redraw("deleting feels") + return delete_feels() + else: + print("okay! please come back any time if you want to delete old feels!") + input("\n\npress to go back to managing your feels.\n\n") + redraw() + return + + def purge_feels(): """handles deleting all feels""" diff --git a/ttbp/util.py b/ttbp/util.py index 5168018..8f31daf 100644 --- a/ttbp/util.py +++ b/ttbp/util.py @@ -31,7 +31,7 @@ import colorama import inflect ## misc globals -BACKS = ['back', 'b', 'q'] +BACKS = ['back', 'b', 'q', ''] NAVS = ['u', 'd'] ## color stuff