jp (base): new confirmOrQuit helper method to ask confirmation to user, and quit if he cancel
This commit is contained in:
parent
c762d0cc31
commit
60eab27872
1 changed files with 20 additions and 18 deletions
|
|
@ -546,6 +546,14 @@ class Jp(object):
|
|||
except AttributeError:
|
||||
pass
|
||||
|
||||
def confirmOrQuit(self, message, cancel_message=_(u"action cancelled by user")):
|
||||
"""Request user to confirm action, and quit if he doesn't"""
|
||||
|
||||
res = raw_input("{} (y/N)? ".format(message))
|
||||
if res not in ("y", "Y"):
|
||||
self.disp(cancel_message)
|
||||
self.quit(C.EXIT_USER_CANCELLED)
|
||||
|
||||
def quitFromSignal(self, errcode=0):
|
||||
"""Same as self.quit, but from a signal handler
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue