Bug 1464869 - Fix flake8/pep8 issue by hand in security/ r=fkiefer
authorSylvestre Ledru <sledru@mozilla.com>
Sun, 27 May 2018 10:36:45 +0200
changeset 421550 9968319230a74eb8c1953444a0e6973c7500a9f8
parent 421549 f9a66e05d90ea6e12616e97b1cc52f9727c4ddc7
child 421551 6576d030231342d51625ac712a9ffc5d29ff9f30
push id34097
push usernbeleuzu@mozilla.com
push dateWed, 06 Jun 2018 16:59:16 +0000
treeherdermozilla-central@223e5900fbbb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfkiefer
bugs1464869
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1464869 - Fix flake8/pep8 issue by hand in security/ r=fkiefer MozReview-Commit-ID: ExDsMJ9KzJQ
security/manager/ssl/tests/unit/pycert.py
security/manager/ssl/tests/unit/pycms.py
security/sandbox/test/mac_register_font.py
--- a/security/manager/ssl/tests/unit/pycert.py
+++ b/security/manager/ssl/tests/unit/pycert.py
@@ -755,9 +755,9 @@ class Certificate(object):
 def main(output, inputPath):
     with open(inputPath) as configStream:
         output.write(Certificate(configStream).toPEM())
 
 
 # When run as a standalone program, this will read a specification from
 # stdin and output the certificate as PEM to stdout.
 if __name__ == '__main__':
-    print Certificate(sys.stdin).toPEM()
+    print(Certificate(sys.stdin).toPEM())
--- a/security/manager/ssl/tests/unit/pycms.py
+++ b/security/manager/ssl/tests/unit/pycms.py
@@ -128,18 +128,20 @@ class CMS(object):
         issuerAndSerialNumber = rfc2315.IssuerAndSerialNumber()
         issuerAndSerialNumber['issuer'] = self.signer.getIssuer()
         issuerAndSerialNumber['serialNumber'] = certificate['tbsCertificate']['serialNumber']
         signerInfo['issuerAndSerialNumber'] = issuerAndSerialNumber
         signerInfo['digestAlgorithm'] = self.pykeyHashToDigestAlgorithm(pykeyHash)
         rsa = rfc2459.AlgorithmIdentifier()
         rsa['algorithm'] = rfc2459.rsaEncryption
         rsa['parameters'] = univ.Null()
-        authenticatedAttributes = self.buildAuthenticatedAttributes(digestValue,
-                                                                    implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))
+        authenticatedAttributes = (
+            self.buildAuthenticatedAttributes(digestValue,
+                                              implicitTag=tag.Tag(tag.tagClassContext,
+                                                                  tag.tagFormatConstructed, 0)))
         authenticatedAttributesTBS = self.buildAuthenticatedAttributes(digestValue)
         signerInfo['authenticatedAttributes'] = authenticatedAttributes
         signerInfo['digestEncryptionAlgorithm'] = rsa
         authenticatedAttributesEncoded = encoder.encode(authenticatedAttributesTBS)
         signature = self.signingKey.sign(authenticatedAttributesEncoded, pykeyHash)
         # signature will be a hexified bit string of the form
         # "'<hex bytes>'H". For some reason that's what BitString wants,
         # but since this is an OCTET STRING, we have to strip off the
@@ -197,9 +199,9 @@ class CMS(object):
             b64 = b64[64:]
         output += '\n-----END PKCS7-----\n'
         return output
 
 
 # When run as a standalone program, this will read a specification from
 # stdin and output the certificate as PEM to stdout.
 if __name__ == '__main__':
-    print CMS(sys.stdin).toPEM()
+    print(CMS(sys.stdin).toPEM())
--- a/security/sandbox/test/mac_register_font.py
+++ b/security/sandbox/test/mac_register_font.py
@@ -4,59 +4,61 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 """
 mac_register_font.py
 
 Mac-specific utility command to register a font file with the OS.
 """
 
-import CoreFoundation
 import CoreText
 import Cocoa
 import argparse
 import sys
 
+
 def main():
     parser = argparse.ArgumentParser()
     parser.add_argument("-v", "--verbose", action="store_true",
-            help="print verbose registration failures", default=False)
+                        help="print verbose registration failures", default=False)
     parser.add_argument("file", nargs='*',
-            help="font file to register or unregister", default=[])
+                        help="font file to register or unregister", default=[])
     parser.add_argument("-u", "--unregister", action="store_true",
-            help="unregister the provided fonts", default=False)
+                        help="unregister the provided fonts", default=False)
     parser.add_argument("-p", "--persist-user", action="store_true",
-            help="permanently register the font", default=False)
+                        help="permanently register the font", default=False)
 
     args = parser.parse_args()
 
     if args.persist_user:
         scope = CoreText.kCTFontManagerScopeUser
         scopeDesc = "user"
     else:
         scope = CoreText.kCTFontManagerScopeSession
         scopeDesc = "session"
 
     failureCount = 0
     for fontPath in args.file:
         fontURL = Cocoa.NSURL.fileURLWithPath_(fontPath)
         (result, error) = register_or_unregister_font(fontURL,
-                args.unregister, scope)
+                                                      args.unregister, scope)
         if result:
             print ("%sregistered font %s with %s scope" %
-                    (("un" if args.unregister else "") , fontPath, scopeDesc))
+                   (("un" if args.unregister else ""), fontPath, scopeDesc))
         else:
             print ("Failed to %sregister font %s with %s scope" %
-                    (("un" if args.unregister else "") , fontPath, scopeDesc))
+                   (("un" if args.unregister else ""), fontPath, scopeDesc))
             if args.verbose:
                 print (error)
             failureCount += 1
 
     sys.exit(failureCount)
 
+
 def register_or_unregister_font(fontURL, unregister, scope):
     return (CoreText.CTFontManagerUnregisterFontsForURL(fontURL,
-        scope, None) if unregister
+                                                        scope, None) if unregister
             else CoreText.CTFontManagerRegisterFontsForURL(fontURL,
-                scope, None))
+                                                           scope, None))
+
 
 if __name__ == '__main__':
     main()