~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-18 10:55:12 UTC
  • mfrom: (5887.1.1 trivial_close_earlier)
  • Revision ID: pqm@pqm.ubuntu.com-20110518105512-8rhaqw4g6a8pnjuo
(jameinel) Close file objects a bit earlier in _seek_and_read. Helps PyPy's
 lazy collector. (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
            "It is recommended that you upgrade by "
155
155
            "running the command\n"
156
156
            "  bzr upgrade %(basedir)s"),
157
 
        locks_steal_dead=(
158
 
            u"Stole dead lock %(lock_url)s %(other_holder_info)s."),
159
157
        )
160
158
 
161
159
    def __init__(self):
206
204
        """
207
205
        return self.get_boolean(prompt % prompt_kwargs)
208
206
 
209
 
    def get_password(self, prompt=u'', **kwargs):
 
207
    def get_password(self, prompt='', **kwargs):
210
208
        """Prompt the user for a password.
211
209
 
212
 
        :param prompt: The prompt to present the user (must be unicode)
 
210
        :param prompt: The prompt to present the user
213
211
        :param kwargs: Arguments which will be expanded into the prompt.
214
212
                       This lets front ends display different things if
215
213
                       they so choose.
306
304
        try:
307
305
            template = self._user_warning_templates[warning_id]
308
306
        except KeyError:
309
 
            fail = "bzr warning: %r, %r" % (warning_id, message_args)
310
 
            warnings.warn("no template for warning: " + fail)   # so tests will fail etc
 
307
            fail = "failed to format warning %r, %r" % (warning_id, message_args)
 
308
            warnings.warn(fail)   # so tests will fail etc
311
309
            return fail
312
310
        try:
313
311
            return template % message_args
314
312
        except ValueError, e:
315
 
            fail = "bzr unprintable warning: %r, %r, %s" % (
 
313
            fail = "failed to format warning %r, %r: %s" % (
316
314
                warning_id, message_args, e)
317
315
            warnings.warn(fail)   # so tests will fail etc
318
316
            return fail
321
319
        """Get a boolean question answered from the user.
322
320
 
323
321
        :param prompt: a message to prompt the user with. Should be a single
324
 
            line without terminating \\n.
 
322
        line without terminating \n.
325
323
        :return: True or False for y/yes or n/no.
326
324
        """
327
325
        raise NotImplementedError(self.get_boolean)
330
328
        """Get an integer from the user.
331
329
 
332
330
        :param prompt: a message to prompt the user with. Could be a multi-line
333
 
            prompt but without a terminating \\n.
 
331
            prompt but without a terminating \n.
334
332
 
335
333
        :return: A signed integer.
336
334
        """
485
483
    def get_integer(self, prompt):
486
484
        return self.responses.pop(0)
487
485
 
488
 
    def get_password(self, prompt=u'', **kwargs):
 
486
    def get_password(self, prompt='', **kwargs):
489
487
        return self.responses.pop(0)
490
488
 
491
489
    def get_username(self, prompt, **kwargs):