[migration] mh.confirm support a new default argument, fix default handling for ASK
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 07 Aug 2009 16:18:28 +0200
changeset 2738 e7e46121a4f9
parent 2737 aaef49a3c39b
child 2739 2403260cb5b4
[migration] mh.confirm support a new default argument, fix default handling for ASK
common/migration.py
--- a/common/migration.py	Fri Aug 07 14:49:48 2009 +0200
+++ b/common/migration.py	Fri Aug 07 16:18:28 2009 +0200
@@ -183,12 +183,12 @@
         if not ask_confirm or self.confirm(msg):
             return meth(*args, **kwargs)
 
-    def confirm(self, question, shell=True, abort=True, retry=False):
+    def confirm(self, question, shell=True, abort=True, retry=False, default='y'):
         """ask for confirmation and return true on positive answer
 
         if `retry` is true the r[etry] answer may return 2
         """
-        possibleanswers = ['Y','n']
+        possibleanswers = ['y','n']
         if abort:
             possibleanswers.append('abort')
         if shell:
@@ -196,7 +196,7 @@
         if retry:
             possibleanswers.append('retry')
         try:
-            answer = ASK.ask(question, possibleanswers, 'Y')
+            answer = ASK.ask(question, possibleanswers, default)
         except (EOFError, KeyboardInterrupt):
             answer = 'abort'
         if answer == 'n':