/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: Vincent Ladeuil
  • Date: 2009-07-02 09:09:35 UTC
  • mto: (4536.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4537.
  • Revision ID: v.ladeuil+lp@free.fr-20090702090935-ya2kx3t8mz1tsf2k
ui.get_boolean can also use bool_from_string.

* bzrlib/ui/__init__.py:
(CLIUIFactory.get_boolean): Simplified by using bool_from_string.

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
        self.stdout = stdout or sys.stdout
193
193
        self.stderr = stderr or sys.stderr
194
194
 
 
195
    _accepted_boolean_strings = dict(y=True, n=False, yes=True, no=False)
 
196
 
195
197
    def get_boolean(self, prompt):
196
198
        while True:
197
199
            self.prompt(prompt + "? [y/n]: ")
198
200
            line = self.stdin.readline()
199
 
            line = line.lower()
200
 
            if line in ('y\n', 'yes\n'):
201
 
                return True
202
 
            if line in ('n\n', 'no\n'):
203
 
                return False
 
201
            line = line.rstrip('\n')
 
202
            val = bool_from_string(line, self._accepted_boolean_strings)
 
203
            if val is not None:
 
204
                return val
204
205
 
205
206
    def get_non_echoed_password(self):
206
207
        isatty = getattr(self.stdin, 'isatty', None)