Bug 1464869 - Fix flake8/pep8 issue by hand in security/ draft
authorSylvestre Ledru <sledru@mozilla.com>
Sun, 27 May 2018 10:36:45 +0200
changeset 804682 0f5a26850149617c17a061d7dc26ce82740ea88a
parent 804681 2603d6c7988cbdb5a6fffa226d9f1e0422969091
child 804683 288dd16da4dbf1982d3b8dc6a6f51bedf066c7db
push id112435
push usersledru@mozilla.com
push dateWed, 06 Jun 2018 11:45:50 +0000
bugs1464869
milestone62.0a1
Bug 1464869 - Fix flake8/pep8 issue by hand in security/ 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()