~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-17 07:52:09 UTC
  • mfrom: (1910.3.4 trivial)
  • Revision ID: pqm@pqm.ubuntu.com-20060817075209-e85a1f9e05ff8b87
(andrew) Trivial fixes to NotImplemented errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
"""Text UI, write output to the console.
20
20
"""
21
21
 
 
22
import getpass
22
23
import sys
23
24
 
24
 
from bzrlib.lazy_import import lazy_import
25
 
lazy_import(globals(), """
26
 
import getpass
27
 
 
28
 
from bzrlib import (
29
 
    progress,
30
 
    osutils,
31
 
    )
32
 
""")
33
 
 
 
25
import bzrlib.progress
 
26
from bzrlib.symbol_versioning import (deprecated_method, 
 
27
        zero_eight)
34
28
from bzrlib.ui import CLIUIFactory
35
29
 
36
30
 
60
54
 
61
55
    def prompt(self, prompt):
62
56
        """Emit prompt on the CLI."""
63
 
        self.stdout.write(prompt)
 
57
        self.stdout.write(prompt + "? [y/n]:")
64
58
        
 
59
    @deprecated_method(zero_eight)
 
60
    def progress_bar(self):
 
61
        """See UIFactory.nested_progress_bar()."""
 
62
        # this in turn is abstract, and creates either a tty or dots
 
63
        # bar depending on what we think of the terminal
 
64
        return bzrlib.progress.ProgressBar()
 
65
 
 
66
    def get_password(self, prompt='', **kwargs):
 
67
        """Prompt the user for a password.
 
68
 
 
69
        :param prompt: The prompt to present the user
 
70
        :param kwargs: Arguments which will be expanded into the prompt.
 
71
                       This lets front ends display different things if
 
72
                       they so choose.
 
73
        :return: The password string, return None if the user 
 
74
                 canceled the request.
 
75
        """
 
76
        prompt = (prompt % kwargs).encode(sys.stdout.encoding, 'replace')
 
77
        prompt += ': '
 
78
        # There's currently no way to say 'i decline to enter a password'
 
79
        # as opposed to 'my password is empty' -- does it matter?
 
80
        return getpass.getpass(prompt)
 
81
 
65
82
    def nested_progress_bar(self):
66
83
        """Return a nested progress bar.
67
84
        
69
86
        may return a tty or dots bar depending on the terminal.
70
87
        """
71
88
        if self._progress_bar_stack is None:
72
 
            self._progress_bar_stack = progress.ProgressBarStack(
 
89
            self._progress_bar_stack = bzrlib.progress.ProgressBarStack(
73
90
                klass=self._bar_type)
74
91
        return self._progress_bar_stack.get_nested()
75
92