~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Martin Pool
  • Date: 2009-06-22 08:33:51 UTC
  • mto: This revision was merged to the branch mainline in revision 4558.
  • Revision ID: mbp@sourcefrog.net-20090622083351-7y1qejei1b3ds1hc
Move NullProgressView and make_progress_view up to UIFactory base class

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
""")
35
35
 
36
 
from bzrlib.ui import CLIUIFactory
 
36
from bzrlib.ui import (
 
37
    CLIUIFactory,
 
38
    NullProgressView,
 
39
    )
37
40
 
38
41
 
39
42
class TextUIFactory(CLIUIFactory):
56
59
            symbol_versioning.warn(symbol_versioning.deprecated_in((1, 11, 0))
57
60
                % "bar_type parameter")
58
61
        # paints progress, network activity, etc
59
 
        self._progress_view = self._make_progress_view()
 
62
        self._progress_view = self.make_progress_view()
60
63
        
61
64
    def clear_term(self):
62
65
        """Prepare the terminal for output.
69
72
        # to clear it.  We might need to separately check for the case of
70
73
        self._progress_view.clear()
71
74
 
72
 
    def _make_progress_view(self):
73
 
        if (os.environ.get('BZR_PROGRESS_BAR') in ('text', None, '')
74
 
            and progress._supports_progress(self.stderr)):
 
75
    def make_progress_view(self):
 
76
        """Construct and return a new ProgressView subclass for this UI.
 
77
        """
 
78
        # if the user specifically requests either text or no progress bars,
 
79
        # always do that.  otherwise, guess based on $TERM and tty presence.
 
80
        if os.environ.get('BZR_PROGRESS_BAR') == 'text':
 
81
            return TextProgressView(self.stderr)
 
82
        elif os.environ.get('BZR_PROGRESS_BAR') == 'none':
 
83
            return NullProgressView()
 
84
        elif progress._supports_progress(self.stderr):
75
85
            return TextProgressView(self.stderr)
76
86
        else:
77
87
            return NullProgressView()
105
115
        self._progress_view.clear()
106
116
 
107
117
 
108
 
class NullProgressView(object):
109
 
    """Soak up and ignore progress information."""
110
 
 
111
 
    def clear(self):
112
 
        pass
113
 
 
114
 
    def show_progress(self, task):
115
 
        pass
116
 
 
117
 
    def show_transport_activity(self, transport, direction, byte_count):
118
 
        pass
119
 
    
120
 
 
121
118
class TextProgressView(object):
122
119
    """Display of progress bar and other information on a tty.
123
120