~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: Martin Pool
  • Date: 2006-03-10 06:29:53 UTC
  • mfrom: (1608 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060310062953-bc1c7ade75c89a7a
[merge] bzr.dev; pycurl not updated for readv yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
displays no output.
29
29
"""
30
30
 
 
31
 
31
32
import bzrlib.progress
 
33
from bzrlib.symbol_versioning import *
32
34
 
33
35
 
34
36
class UIFactory(object):
37
39
    This tells the library how to display things to the user.  Through this
38
40
    layer different applications can choose the style of UI.
39
41
    """
 
42
 
 
43
    def __init__(self):
 
44
        super(UIFactory, self).__init__()
 
45
        self._progress_bar_stack = None
 
46
 
 
47
    @deprecated_method(zero_eight)
40
48
    def progress_bar(self):
41
 
        """Return a progress bar object"""
42
 
        raise NotImplementedError
 
49
        """See UIFactory.nested_progress_bar()."""
 
50
        raise NotImplementedError(self.progress_bar)
43
51
 
44
52
    def get_password(self, prompt='', **kwargs):
45
53
        """Prompt the user for a password.
51
59
        :return: The password string, return None if the user 
52
60
                 canceled the request.
53
61
        """
54
 
        raise NotImplementedError
 
62
        raise NotImplementedError(self.get_password)
55
63
        
 
64
    def nested_progress_bar(self):
 
65
        """Return a nested progress bar.
 
66
 
 
67
        When the bar has been finished with, it should be released bu calling
 
68
        bar.finished().
 
69
        """
 
70
        raise NotImplementedError(self.nested_progress_bar)
 
71
 
56
72
 
57
73
class SilentUIFactory(UIFactory):
58
74
    """A UI Factory which never prints anything.
59
75
 
60
76
    This is the default UI, if another one is never registered.
61
77
    """
 
78
 
 
79
    @deprecated_method(zero_eight)
62
80
    def progress_bar(self):
 
81
        """See UIFactory.nested_progress_bar()."""
63
82
        return bzrlib.progress.DummyProgress()
64
83
 
65
84
    def get_password(self, prompt='', **kwargs):
66
85
        return None
67
86
 
 
87
    def nested_progress_bar(self):
 
88
        if self._progress_bar_stack is None:
 
89
            self._progress_bar_stack = bzrlib.progress.ProgressBarStack(
 
90
                klass=bzrlib.progress.DummyProgress)
 
91
        return self._progress_bar_stack.get_nested()
 
92
 
68
93
 
69
94
ui_factory = SilentUIFactory()
70
95
"""IMPORTANT: never import this symbol directly. ONLY ever access it as