~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: Robert Collins
  • Date: 2010-01-08 06:33:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4944.
  • Revision ID: robertc@robertcollins.net-20100108063305-qxgq2t7prgp0op1j
Adjust errors.py to fix missing references to 'warn'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
109
109
 
110
110
    def __init__(self):
111
111
        self._task_stack = []
112
 
        self._quiet = False
113
 
 
114
 
    def be_quiet(self, state):
115
 
        """Tell the UI to be more quiet, or not.
116
 
 
117
 
        Typically this suppresses progress bars; the application may also look
118
 
        at ui_factory.is_quiet().
119
 
        """
120
 
        self._quiet = state
121
112
 
122
113
    def get_password(self, prompt='', **kwargs):
123
114
        """Prompt the user for a password.
134
125
        """
135
126
        raise NotImplementedError(self.get_password)
136
127
 
137
 
    def is_quiet(self):
138
 
        return self._quiet
139
 
 
140
128
    def make_output_stream(self, encoding=None, encoding_type=None):
141
129
        """Get a stream for sending out bulk text data.
142
130
 
275
263
        """Show an error message (not an exception) to the user.
276
264
        
277
265
        The message should not have an error prefix or trailing newline.  That
278
 
        will be added by the factory if appropriate.
 
266
        will be added by the factory if appropriate. 
279
267
        """
280
268
        raise NotImplementedError(self.show_error)
281
269
 
287
275
        """Show a warning to the user."""
288
276
        raise NotImplementedError(self.show_warning)
289
277
 
290
 
    def warn_cross_format_fetch(self, from_format, to_format):
291
 
        """Warn about a potentially slow cross-format transfer"""
292
 
        # See <https://launchpad.net/bugs/456077> asking for a warning here
293
 
        trace.warning("Doing on-the-fly conversion from %s to %s.\n"
294
 
            "This may take some time. Upgrade the repositories to the "
295
 
            "same format for better performance.\n" %
296
 
            (from_format, to_format))
297
278
 
298
279
 
299
280
class SilentUIFactory(UIFactory):
315
296
    def get_username(self, prompt, **kwargs):
316
297
        return None
317
298
 
318
 
    def _make_output_stream_explicit(self, encoding, encoding_type):
319
 
        return NullOutputStream(encoding)
320
 
 
321
299
    def show_error(self, msg):
322
300
        pass
323
301
 
383
361
 
384
362
    def log_transport_activity(self, display=False):
385
363
        pass
386
 
 
387
 
 
388
 
class NullOutputStream(object):
389
 
    """Acts like a file, but discard all output."""
390
 
 
391
 
    def __init__(self, encoding):
392
 
        self.encoding = encoding
393
 
 
394
 
    def write(self, data):
395
 
        pass
396
 
 
397
 
    def writelines(self, data):
398
 
        pass
399
 
 
400
 
    def close(self):
401
 
        pass