/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/text.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-20 14:51:03 UTC
  • mfrom: (0.8.23 version_info)
  • mto: This revision was merged to the branch mainline in revision 2028.
  • Revision ID: john@arbash-meinel.com-20060920145103-02725c6d6c886040
[merge] version-info plugin, and cleanup for layout in bzr

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