~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

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 sys
 
23
 
 
24
from bzrlib.lazy_import import lazy_import
 
25
lazy_import(globals(), """
22
26
import getpass
23
 
import sys
24
 
 
25
 
import bzrlib.progress
26
 
from bzrlib.symbol_versioning import (deprecated_method, 
27
 
        zero_eight)
 
27
 
 
28
from bzrlib import (
 
29
    progress,
 
30
    osutils,
 
31
    )
 
32
""")
 
33
 
 
34
from bzrlib.symbol_versioning import (
 
35
    deprecated_method,
 
36
    zero_eight,
 
37
    )
28
38
from bzrlib.ui import CLIUIFactory
29
39
 
30
40
 
54
64
 
55
65
    def prompt(self, prompt):
56
66
        """Emit prompt on the CLI."""
57
 
        self.stdout.write(prompt + "? [y/n]:")
 
67
        self.stdout.write(prompt)
58
68
        
59
69
    @deprecated_method(zero_eight)
60
70
    def progress_bar(self):
61
71
        """See UIFactory.nested_progress_bar()."""
62
72
        # this in turn is abstract, and creates either a tty or dots
63
73
        # 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)
 
74
        return progress.ProgressBar()
81
75
 
82
76
    def nested_progress_bar(self):
83
77
        """Return a nested progress bar.
86
80
        may return a tty or dots bar depending on the terminal.
87
81
        """
88
82
        if self._progress_bar_stack is None:
89
 
            self._progress_bar_stack = bzrlib.progress.ProgressBarStack(
 
83
            self._progress_bar_stack = progress.ProgressBarStack(
90
84
                klass=self._bar_type)
91
85
        return self._progress_bar_stack.get_nested()
92
86