From ca8c642add498a30900114196cc3a8ba650afcbe Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 20 Feb 2020 18:57:08 -0800 Subject: [PATCH] Add "Are you sure you want to quit" to erepl. --- frontends/etiquette_repl/etiquette_repl_launch.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontends/etiquette_repl/etiquette_repl_launch.py b/frontends/etiquette_repl/etiquette_repl_launch.py index 9000125..3c699ac 100644 --- a/frontends/etiquette_repl/etiquette_repl_launch.py +++ b/frontends/etiquette_repl/etiquette_repl_launch.py @@ -10,6 +10,8 @@ import os import sys import traceback +from voussoirkit import getpermission + import etiquette P = etiquette.photodb.PhotoDB() @@ -38,9 +40,19 @@ get = P.get_tag def erepl_argparse(args): if args.exec_statement: exec(args.exec_statement) + P.commit() else: import code - code.interact(banner='', local=dict(globals(), **locals())) + while True: + try: + code.interact(banner='', local=dict(globals(), **locals())) + except SystemExit: + pass + if len(P.savepoints) == 0: + break + print('You have uncommited changes, are you sure you want to quit?') + if getpermission.getpermission(): + break def main(argv): parser = argparse.ArgumentParser()