src/modules/actions/signature.py
changeset 3158 58c9c2c21e67
parent 2962 ce8cd4c07986
child 3164 21e62efb9dd7
--- a/src/modules/actions/signature.py	Wed Jan 21 17:54:10 2015 -0800
+++ b/src/modules/actions/signature.py	Mon Jan 26 01:30:45 2015 -0800
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
 #
 
 import os
@@ -108,10 +108,12 @@
                 for pth in chain_certs:
                         if not os.path.exists(pth):
                                 raise pkg.actions.ActionDataError(
-                                    _("No such file: '%s'.") % pth, path=pth)
+                                    _("No such file: '{0}'.").format(pth),
+                                    path=pth)
                         elif os.path.isdir(pth):
                                 raise pkg.actions.ActionDataError(
-                                    _("'%s' is not a file.") % pth, path=pth)
+                                    _("'{0}' is not a file.").format(pth),
+                                    path=pth)
                         file_opener = self.make_opener(pth)
                         self.chain_cert_openers.append(file_opener)
                         self.attrs.setdefault("chain.sizes", [])
@@ -368,7 +370,7 @@
 
                 for s in valid_sig_algs:
                         for h in valid_hash_algs:
-                                t = "%s-%s" % (s, h)
+                                t = "{0}-{1}".format(s, h)
                                 if val == t:
                                         return s, h
                 for h in valid_hash_algs:
@@ -412,7 +414,7 @@
                         dgst = m2.EVP.MessageDigest(self.hash_alg)
                         res = dgst.update(self.actions_to_str(acts, ver))
                         assert res == 1, \
-                            "Res was expected to be 1, but was %s" % res
+                            "Res was expected to be 1, but was {0}".format(res)
                         computed_hash = dgst.final()
                         # The attrs value is stored in hex so that it's easy
                         # to read.
@@ -420,7 +422,7 @@
                             computed_hash:
                                 raise apx.UnverifiedSignature(self,
                                     _("The signature value did not match the "
-                                    "expected value. action: %s") % self)
+                                    "expected value. action: {0}").format(self))
                         return True
                 # Verify a signature that's not just a hash.
                 if self.sig_alg is None:
@@ -455,7 +457,7 @@
                 if not res:
                         raise apx.UnverifiedSignature(self,
                             _("The signature value did not match the expected "
-                            "value. Res: %s") % res)
+                            "value. Res: {0}").format(res))
                 return True
 
         def set_signature(self, acts, key_path=None, chain_paths=misc.EmptyI,
@@ -490,7 +492,7 @@
                         res = dgst.update(self.actions_to_str(acts,
                             generic.Action.sig_version))
                         assert res == 1, \
-                            "Res was expected to be 1, it was %s" % res
+                            "Res was expected to be 1, it was {0}".format(res)
                         self.attrs["value"] = \
                             misc.binary_to_hex(dgst.final())
                 else:
@@ -502,9 +504,9 @@
                         try:
                                 priv_key = m2.RSA.load_key(key_path)
                         except m2.RSA.RSAError:
-                                raise apx.BadFileFormat(_("%s was expected to "
+                                raise apx.BadFileFormat(_("{0} was expected to "
                                     "be a RSA key but could not be read "
-                                    "correctly.") % key_path)
+                                    "correctly.").format(key_path))
                         signer = m2.EVP.PKey(md=self.hash_alg)
                         signer.assign_rsa(priv_key, 1)
                         del priv_key