~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-08 11:01:15 UTC
  • mfrom: (6123.1.16 gpg-typo)
  • Revision ID: pqm@cupuasso-20110908110115-gbb9benwkdksvzk5
(jelmer) Fix a typo (invalid format identifier) in an error message in
 bzrlib.gpg. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    trace,
32
32
    ui,
33
33
    )
34
 
from bzrlib.i18n import (
35
 
    gettext, 
36
 
    ngettext,
37
 
    )
38
34
""")
39
35
 
 
36
class i18n:
 
37
    """this class is ready to use bzrlib.i18n but bzrlib.i18n is not ready to
 
38
    use so here is a stub until it is"""
 
39
    @staticmethod
 
40
    def gettext(string):
 
41
        return string
 
42
        
 
43
    @staticmethod
 
44
    def ngettext(single, plural, number):
 
45
        if number == 1:
 
46
            return single
 
47
        else:
 
48
            return plural
 
49
 
40
50
#verification results
41
51
SIGNATURE_VALID = 0
42
52
SIGNATURE_KEY_MISSING = 1
113
123
        return (count, result, all_verifiable)
114
124
 
115
125
    def valid_commits_message(self, count):
116
 
        return gettext(u"{0} commits with valid signatures").format(
 
126
        return i18n.gettext(u"{0} commits with valid signatures").format(
117
127
                                        count[SIGNATURE_VALID])            
118
128
 
119
129
    def unknown_key_message(self, count):
120
 
        return ngettext(u"{0} commit with unknown key",
 
130
        return i18n.ngettext(u"{0} commit with unknown key",
121
131
                             u"{0} commits with unknown keys",
122
132
                             count[SIGNATURE_KEY_MISSING]).format(
123
133
                                        count[SIGNATURE_KEY_MISSING])
124
134
 
125
135
    def commit_not_valid_message(self, count):
126
 
        return ngettext(u"{0} commit not valid",
 
136
        return i18n.ngettext(u"{0} commit not valid",
127
137
                             u"{0} commits not valid",
128
138
                             count[SIGNATURE_NOT_VALID]).format(
129
139
                                            count[SIGNATURE_NOT_VALID])
130
140
 
131
141
    def commit_not_signed_message(self, count):
132
 
        return ngettext(u"{0} commit not signed",
 
142
        return i18n.ngettext(u"{0} commit not signed",
133
143
                             u"{0} commits not signed",
134
144
                             count[SIGNATURE_NOT_SIGNED]).format(
135
145
                                        count[SIGNATURE_NOT_SIGNED])
136
146
 
137
147
    def expired_commit_message(self, count):
138
 
        return ngettext(u"{0} commit with key now expired",
139
 
                        u"{0} commits with key now expired",
140
 
                        count[SIGNATURE_EXPIRED]).format(
 
148
        return i18n.ngettext(u"{0} commit with key now expired",
 
149
                             u"{0} commits with key now expired",
 
150
                             count[SIGNATURE_EXPIRED]).format(
141
151
                                        count[SIGNATURE_EXPIRED])
142
152
 
143
153
 
314
324
                acceptable_keys_config = str(acceptable_keys_config)
315
325
        except UnicodeEncodeError:
316
326
            #gpg Context.keylist(pattern) does not like unicode
317
 
            raise errors.BzrCommandError(gettext('Only ASCII permitted in option names'))
 
327
            raise errors.BzrCommandError('Only ASCII permitted in option names')
318
328
 
319
329
        if acceptable_keys_config is not None:
320
330
            key_patterns = acceptable_keys_config
332
342
                    self.acceptable_keys.append(key.subkeys[0].fpr)
333
343
                    trace.mutter("Added acceptable key: " + key.subkeys[0].fpr)
334
344
                if not found_key:
335
 
                    trace.note(gettext(
 
345
                    trace.note(i18n.gettext(
336
346
                            "No GnuPG key results for pattern: {0}"
337
347
                                ).format(pattern))
338
348
 
376
386
                signers[uid] += 1
377
387
        result = []
378
388
        for uid, number in signers.items():
379
 
             result.append( ngettext(u"{0} signed {1} commit", 
 
389
             result.append( i18n.ngettext(u"{0} signed {1} commit", 
380
390
                             u"{0} signed {1} commits",
381
391
                             number).format(uid, number) )
382
392
        return result
393
403
                signers[authors] += 1
394
404
        result = []
395
405
        for authors, number in signers.items():
396
 
            result.append( ngettext(u"{0} commit by author {1}", 
 
406
            result.append( i18n.ngettext(u"{0} commit by author {1}", 
397
407
                                 u"{0} commits by author {1}",
398
408
                                 number).format(number, authors) )
399
409
        return result
409
419
                signers[authors] += 1
410
420
        result = []
411
421
        for authors, number in signers.items():
412
 
            result.append( ngettext(u"{0} commit by author {1}", 
 
422
            result.append( i18n.ngettext(u"{0} commit by author {1}", 
413
423
                                 u"{0} commits by author {1}",
414
424
                                 number).format(number, authors) )
415
425
        return result
423
433
                signers[fingerprint] += 1
424
434
        result = []
425
435
        for fingerprint, number in signers.items():
426
 
            result.append( ngettext(u"Unknown key {0} signed {1} commit", 
 
436
            result.append( i18n.ngettext(u"Unknown key {0} signed {1} commit", 
427
437
                                 u"Unknown key {0} signed {1} commits",
428
438
                                 number).format(fingerprint, number) )
429
439
        return result
441
451
                fingerprint_to_authors[fingerprint] = authors
442
452
        result = []
443
453
        for fingerprint, number in signers.items():
444
 
            result.append(ngettext(u"{0} commit by author {1} with "\
445
 
                                    "key {2} now expired", 
446
 
                                   u"{0} commits by author {1} with key {2} now "\
447
 
                                    "expired",
448
 
                                    number).format(number,
 
454
            result.append( i18n.ngettext(u"{0} commit by author {1} with "\
 
455
                                          "key {2} now expired", 
 
456
                                 u"{0} commits by author {1} with key {2} now "\
 
457
                                  "expired",
 
458
                                 number).format(number,
449
459
                            fingerprint_to_authors[fingerprint], fingerprint) )
450
460
        return result
451
461
 
452
462
    def valid_commits_message(self, count):
453
463
        """returns message for number of commits"""
454
 
        return gettext(u"{0} commits with valid signatures").format(
 
464
        return i18n.gettext(u"{0} commits with valid signatures").format(
455
465
                                        count[SIGNATURE_VALID])
456
466
 
457
467
    def unknown_key_message(self, count):
458
468
        """returns message for number of commits"""
459
 
        return ngettext(u"{0} commit with unknown key",
460
 
                        u"{0} commits with unknown keys",
461
 
                        count[SIGNATURE_KEY_MISSING]).format(
 
469
        return i18n.ngettext(u"{0} commit with unknown key",
 
470
                             u"{0} commits with unknown keys",
 
471
                             count[SIGNATURE_KEY_MISSING]).format(
462
472
                                        count[SIGNATURE_KEY_MISSING])
463
473
 
464
474
    def commit_not_valid_message(self, count):
465
475
        """returns message for number of commits"""
466
 
        return ngettext(u"{0} commit not valid",
467
 
                        u"{0} commits not valid",
468
 
                        count[SIGNATURE_NOT_VALID]).format(
 
476
        return i18n.ngettext(u"{0} commit not valid",
 
477
                             u"{0} commits not valid",
 
478
                             count[SIGNATURE_NOT_VALID]).format(
469
479
                                            count[SIGNATURE_NOT_VALID])
470
480
 
471
481
    def commit_not_signed_message(self, count):
472
482
        """returns message for number of commits"""
473
 
        return ngettext(u"{0} commit not signed",
474
 
                        u"{0} commits not signed",
475
 
                        count[SIGNATURE_NOT_SIGNED]).format(
 
483
        return i18n.ngettext(u"{0} commit not signed",
 
484
                             u"{0} commits not signed",
 
485
                             count[SIGNATURE_NOT_SIGNED]).format(
476
486
                                        count[SIGNATURE_NOT_SIGNED])
477
487
 
478
488
    def expired_commit_message(self, count):
479
489
        """returns message for number of commits"""
480
 
        return ngettext(u"{0} commit with key now expired",
481
 
                        u"{0} commits with key now expired",
482
 
                        count[SIGNATURE_EXPIRED]).format(
483
 
                                    count[SIGNATURE_EXPIRED])
 
490
        return i18n.ngettext(u"{0} commit with key now expired",
 
491
                             u"{0} commits with key now expired",
 
492
                             count[SIGNATURE_EXPIRED]).format(
 
493
                                        count[SIGNATURE_EXPIRED])