]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/Capsule.py
BaseTools: refactor and remove un-needed use of .keys() on dictionaries
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Capsule.py
index d025f0c2b35f113efb0893234a4a061415a97667..fbd48f3c6d7663bb37633f8a923190fc6274f05c 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # generate capsule\r
 #\r
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -141,6 +141,11 @@ class Capsule (CapsuleClassObject) :
             Content.write(File.read())\r
             File.close()\r
         for fmp in self.FmpPayloadList:\r
+            if fmp.Existed:\r
+                FwMgrHdr.write(pack('=Q', PreSize))\r
+                PreSize += len(fmp.Buffer)\r
+                Content.write(fmp.Buffer)\r
+                continue\r
             if fmp.ImageFile:\r
                 for Obj in fmp.ImageFile:\r
                     fmp.ImageFile = Obj.GenCapsuleSubItem()\r
@@ -154,7 +159,7 @@ class Capsule (CapsuleClassObject) :
                 if not os.path.isabs(fmp.ImageFile):\r
                     CapInputFile = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, fmp.ImageFile)\r
                 CapOutputTmp = os.path.join(GenFdsGlobalVariable.FvDir, self.UiCapsuleName) + '.tmp'\r
-                if ExternalTool == None:\r
+                if ExternalTool is None:\r
                     EdkLogger.error("GenFds", GENFDS_ERROR, "No tool found with GUID %s" % fmp.Certificate_Guid)\r
                 else:\r
                     CmdOption += ExternalTool\r
@@ -169,12 +174,12 @@ class Capsule (CapsuleClassObject) :
                     dwLength = 4 + 2 + 2 + 16 + 16 + 256 + 256\r
                 fmp.ImageFile = CapOutputTmp\r
                 AuthData = [fmp.MonotonicCount, dwLength, WIN_CERT_REVISION, WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid]\r
-                Buffer = fmp.GenCapsuleSubItem(AuthData)\r
+                fmp.Buffer = fmp.GenCapsuleSubItem(AuthData)\r
             else:\r
-                Buffer = fmp.GenCapsuleSubItem()\r
+                fmp.Buffer = fmp.GenCapsuleSubItem()\r
             FwMgrHdr.write(pack('=Q', PreSize))\r
-            PreSize += len(Buffer)\r
-            Content.write(Buffer)\r
+            PreSize += len(fmp.Buffer)\r
+            Content.write(fmp.Buffer)\r
         BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue())\r
         Header.write(pack('=I', HdrSize + BodySize))\r
         #\r
@@ -196,7 +201,7 @@ class Capsule (CapsuleClassObject) :
     #   @retval string      Generated Capsule file path\r
     #\r
     def GenCapsule(self):\r
-        if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict.keys():\r
+        if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:\r
             return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']\r
 \r
         GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)\r
@@ -246,11 +251,11 @@ class Capsule (CapsuleClassObject) :
 \r
         CapInfFile.writelines("[options]" + T_CHAR_LF)\r
 \r
-        for Item in self.TokensDict.keys():\r
+        for Item in self.TokensDict:\r
             CapInfFile.writelines("EFI_"                    + \\r
                                   Item                      + \\r
                                   ' = '                     + \\r
-                                  self.TokensDict.get(Item) + \\r
+                                  self.TokensDict[Item]     + \\r
                                   T_CHAR_LF)\r
 \r
         return CapInfFile\r