~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2008-09-26 22:14:42 UTC
  • mto: This revision was merged to the branch mainline in revision 3747.
  • Revision ID: john@arbash-meinel.com-20080926221442-3r67j99sr9rwe9w0
Make message optional, don't check the memory flag directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
 
18
 
 
19
17
"""UI abstraction.
20
18
 
21
19
This tells the library how to display things to the user.  Through this
35
33
import getpass
36
34
 
37
35
from bzrlib import (
 
36
    errors,
38
37
    osutils,
39
38
    progress,
40
39
    trace,
41
40
    )
42
41
""")
43
42
 
44
 
from bzrlib.symbol_versioning import (deprecated_method, zero_eight)
45
 
 
46
43
 
47
44
class UIFactory(object):
48
45
    """UI abstraction.
55
52
        super(UIFactory, self).__init__()
56
53
        self._progress_bar_stack = None
57
54
 
58
 
    @deprecated_method(zero_eight)
59
 
    def progress_bar(self):
60
 
        """See UIFactory.nested_progress_bar()."""
61
 
        raise NotImplementedError(self.progress_bar)
62
 
 
63
55
    def get_password(self, prompt='', **kwargs):
64
56
        """Prompt the user for a password.
65
57
 
132
124
                return False
133
125
 
134
126
    def get_non_echoed_password(self, prompt):
 
127
        if not sys.stdin.isatty():
 
128
            raise errors.NotATerminal()
135
129
        encoding = osutils.get_terminal_encoding()
136
130
        return getpass.getpass(prompt.encode(encoding, 'replace'))
137
131
 
161
155
    This is the default UI, if another one is never registered.
162
156
    """
163
157
 
164
 
    @deprecated_method(zero_eight)
165
 
    def progress_bar(self):
166
 
        """See UIFactory.nested_progress_bar()."""
167
 
        return progress.DummyProgress()
168
 
 
169
158
    def get_password(self, prompt='', **kwargs):
170
159
        return None
171
160