~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Martin Pool
  • Date: 2009-07-19 01:05:42 UTC
  • mto: This revision was merged to the branch mainline in revision 4558.
  • Revision ID: mbp@sourcefrog.net-20090719010542-34bzx1i5ynfvs6zd
TextUIFactory should cope with EOF when in get_boolean

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
        self._progress_view.clear()
74
74
 
75
75
    def get_boolean(self, prompt):
76
 
        # FIXME: make a regexp and handle case variations as well.
77
76
        while True:
78
77
            self.prompt(prompt + "? [y/n]: ")
79
 
            line = self.stdin.readline()
 
78
            line = self.stdin.readline().lower()
80
79
            if line in ('y\n', 'yes\n'):
81
80
                return True
82
 
            if line in ('n\n', 'no\n'):
 
81
            elif line in ('n\n', 'no\n'):
83
82
                return False
 
83
            elif line in ('', None):
 
84
                # end-of-file; possibly should raise an error here instead
 
85
                return None
84
86
 
85
87
    def get_non_echoed_password(self):
86
88
        isatty = getattr(self.stdin, 'isatty', None)