~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-15 08:31:55 UTC
  • mfrom: (6372.2.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20111215083155-gfpcyinaaxpbfjyq
(vila) Remove spurious spaces (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
 
115
115
    def valid_commits_message(self, count):
116
116
        return gettext(u"{0} commits with valid signatures").format(
117
 
                                        count[SIGNATURE_VALID])            
 
117
                                        count[SIGNATURE_VALID])
118
118
 
119
119
    def unknown_key_message(self, count):
120
120
        return ngettext(u"{0} commit with unknown key",
235
235
 
236
236
        signature = StringIO(content)
237
237
        plain_output = StringIO()
238
 
        
239
238
        try:
240
239
            result = self.context.verify(signature, None, plain_output)
241
240
        except gpgme.GpgmeError,error:
245
244
        # test_verify_invalid()
246
245
        if len(result) == 0:
247
246
            return SIGNATURE_NOT_VALID, None
248
 
        # User has specified a list of acceptable keys, check our result is in it.
249
 
        # test_verify_unacceptable_key()
 
247
        # User has specified a list of acceptable keys, check our result is in
 
248
        # it.  test_verify_unacceptable_key()
250
249
        fingerprint = result[0].fpr
251
250
        if self.acceptable_keys is not None:
252
 
            if not fingerprint in self.acceptable_keys:                
 
251
            if not fingerprint in self.acceptable_keys:
253
252
                return SIGNATURE_KEY_MISSING, fingerprint[-8:]
254
253
        # Check the signature actually matches the testament.
255
254
        # test_verify_bad_testament()
256
255
        if testament != plain_output.getvalue():
257
 
            return SIGNATURE_NOT_VALID, None 
 
256
            return SIGNATURE_NOT_VALID, None
258
257
        # Yay gpgme set the valid bit.
259
258
        # Can't write a test for this one as you can't set a key to be
260
259
        # trusted using gpgme.
271
270
        # test_verify_unknown_key()
272
271
        if result[0].summary & gpgme.SIGSUM_KEY_MISSING:
273
272
            return SIGNATURE_KEY_MISSING, fingerprint[-8:]
274
 
        # Summary isn't set if sig is valid but key is untrusted
275
 
        # but if user has explicity set the key as acceptable we can validate it.
 
273
        # Summary isn't set if sig is valid but key is untrusted but if user
 
274
        # has explicity set the key as acceptable we can validate it.
276
275
        if result[0].summary == 0 and self.acceptable_keys is not None:
277
276
            if fingerprint in self.acceptable_keys:
278
277
                # test_verify_untrusted_but_accepted()
279
 
                return SIGNATURE_VALID, None 
 
278
                return SIGNATURE_VALID, None
280
279
        # test_verify_valid_but_untrusted()
281
280
        if result[0].summary == 0 and self.acceptable_keys is None:
282
281
            return SIGNATURE_NOT_VALID, None
312
311
            if isinstance(acceptable_keys_config, unicode):
313
312
                acceptable_keys_config = str(acceptable_keys_config)
314
313
        except UnicodeEncodeError:
315
 
            #gpg Context.keylist(pattern) does not like unicode
316
 
            raise errors.BzrCommandError(gettext('Only ASCII permitted in option names'))
 
314
            # gpg Context.keylist(pattern) does not like unicode
 
315
            raise errors.BzrCommandError(
 
316
                gettext('Only ASCII permitted in option names'))
317
317
 
318
318
        if acceptable_keys_config is not None:
319
319
            key_patterns = acceptable_keys_config
320
 
        if command_line_input is not None: #command line overrides config
 
320
        if command_line_input is not None: # command line overrides config
321
321
            key_patterns = command_line_input
322
322
        if key_patterns is not None:
323
323
            patterns = key_patterns.split(",")
375
375
                signers[uid] += 1
376
376
        result = []
377
377
        for uid, number in signers.items():
378
 
             result.append( ngettext(u"{0} signed {1} commit", 
 
378
             result.append( ngettext(u"{0} signed {1} commit",
379
379
                             u"{0} signed {1} commits",
380
380
                             number).format(uid, number) )
381
381
        return result
392
392
                signers[authors] += 1
393
393
        result = []
394
394
        for authors, number in signers.items():
395
 
            result.append( ngettext(u"{0} commit by author {1}", 
 
395
            result.append( ngettext(u"{0} commit by author {1}",
396
396
                                 u"{0} commits by author {1}",
397
397
                                 number).format(number, authors) )
398
398
        return result
408
408
                signers[authors] += 1
409
409
        result = []
410
410
        for authors, number in signers.items():
411
 
            result.append( ngettext(u"{0} commit by author {1}", 
 
411
            result.append( ngettext(u"{0} commit by author {1}",
412
412
                                 u"{0} commits by author {1}",
413
413
                                 number).format(number, authors) )
414
414
        return result
422
422
                signers[fingerprint] += 1
423
423
        result = []
424
424
        for fingerprint, number in signers.items():
425
 
            result.append( ngettext(u"Unknown key {0} signed {1} commit", 
 
425
            result.append( ngettext(u"Unknown key {0} signed {1} commit",
426
426
                                 u"Unknown key {0} signed {1} commits",
427
427
                                 number).format(fingerprint, number) )
428
428
        return result
440
440
                fingerprint_to_authors[fingerprint] = authors
441
441
        result = []
442
442
        for fingerprint, number in signers.items():
443
 
            result.append(ngettext(u"{0} commit by author {1} with "\
444
 
                                    "key {2} now expired", 
445
 
                                   u"{0} commits by author {1} with key {2} now "\
446
 
                                    "expired",
447
 
                                    number).format(number,
448
 
                            fingerprint_to_authors[fingerprint], fingerprint) )
 
443
            result.append(
 
444
                ngettext(u"{0} commit by author {1} with key {2} now expired",
 
445
                         u"{0} commits by author {1} with key {2} now expired",
 
446
                         number).format(
 
447
                    number, fingerprint_to_authors[fingerprint], fingerprint) )
449
448
        return result
450
449
 
451
450
    def valid_commits_message(self, count):