]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/Fv.py
BaseTools: fix None comparisons
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Fv.py
index d5922c040cd30e39e5468e659576905e8ecbba30..aae644bef9058d3a415b910584f236ca5705c41d 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FV generation\r
 #\r
-#  Copyright (c) 2007 - 2017, 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
@@ -70,14 +70,14 @@ class FV (FvClassObject):
     #\r
     def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :\r
 \r
-        if BaseAddress == None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys():\r
+        if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys():\r
             return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']\r
         \r
         #\r
         # Check whether FV in Capsule is in FD flash region.\r
         # If yes, return error. Doesn't support FV in Capsule image is also in FD flash region.\r
         #\r
-        if self.CapsuleName != None:\r
+        if self.CapsuleName is not None:\r
             for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
                 FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]\r
                 for RegionObj in FdObj.RegionList:\r
@@ -94,7 +94,7 @@ class FV (FvClassObject):
         GenFdsGlobalVariable.LargeFileInFvFlags.append(False)\r
         FFSGuid = None\r
         \r
-        if self.FvBaseAddress != None:\r
+        if self.FvBaseAddress is not None:\r
             BaseAddress = self.FvBaseAddress\r
         if not Flag:\r
             self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict)\r
@@ -121,7 +121,7 @@ class FV (FvClassObject):
                     continue\r
             if GenFdsGlobalVariable.EnableGenfdsMultiThread and GenFdsGlobalVariable.ModuleFile and GenFdsGlobalVariable.ModuleFile.Path.find(os.path.normpath(FfsFile.InfFileName)) == -1:\r
                 continue\r
-            FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress, IsMakefile=Flag)\r
+            FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress, IsMakefile=Flag, FvName=self.UiFvName)\r
             FfsFileList.append(FileName)\r
             if not Flag:\r
                 self.FvInfFile.writelines("EFI_FILE_NAME = " + \\r
@@ -136,7 +136,7 @@ class FV (FvClassObject):
         FvOutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName)\r
         FvOutputFile = FvOutputFile + '.Fv'\r
         # BUGBUG: FvOutputFile could be specified from FDF file (FV section, CreateFile statement)\r
-        if self.CreateFileName != None:\r
+        if self.CreateFileName is not None:\r
             FvOutputFile = self.CreateFileName\r
 \r
         if Flag:\r
@@ -163,7 +163,7 @@ class FV (FvClassObject):
             NewFvInfo = None\r
             if os.path.exists (FvInfoFileName):\r
                 NewFvInfo = open(FvInfoFileName, 'r').read()\r
-            if NewFvInfo != None and NewFvInfo != OrigFvInfo:\r
+            if NewFvInfo is not None and NewFvInfo != OrigFvInfo:\r
                 FvChildAddr = []\r
                 AddFileObj = open(FvInfoFileName, 'r')\r
                 AddrStrings = AddFileObj.readlines()\r
@@ -179,7 +179,7 @@ class FV (FvClassObject):
                 if FvChildAddr != []:\r
                     # Update Ffs again\r
                     for FfsFile in self.FfsList :\r
-                        FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress, IsMakefile=Flag)\r
+                        FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress, IsMakefile=Flag, FvName=self.UiFvName)\r
 \r
                     if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:\r
                         FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID;\r
@@ -273,16 +273,16 @@ class FV (FvClassObject):
         # Add [Options]\r
         #\r
         self.FvInfFile.writelines("[options]" + T_CHAR_LF)\r
-        if BaseAddress != None :\r
+        if BaseAddress is not None :\r
             self.FvInfFile.writelines("EFI_BASE_ADDRESS = " + \\r
                                        BaseAddress          + \\r
                                        T_CHAR_LF)\r
 \r
-        if BlockSize != None:\r
+        if BlockSize is not None:\r
             self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \\r
                                       '0x%X' %BlockSize    + \\r
                                       T_CHAR_LF)\r
-            if BlockNum != None:\r
+            if BlockNum is not None:\r
                 self.FvInfFile.writelines("EFI_NUM_BLOCKS   = "  + \\r
                                       ' 0x%X' %BlockNum    + \\r
                                       T_CHAR_LF)\r
@@ -293,20 +293,20 @@ class FV (FvClassObject):
                     self.FvInfFile.writelines("EFI_BLOCK_SIZE  = 0x1" + T_CHAR_LF)\r
             \r
             for BlockSize in self.BlockSizeList :\r
-                if BlockSize[0] != None:\r
+                if BlockSize[0] is not None:\r
                     self.FvInfFile.writelines("EFI_BLOCK_SIZE  = "  + \\r
                                           '0x%X' %BlockSize[0]    + \\r
                                           T_CHAR_LF)\r
 \r
-                if BlockSize[1] != None:\r
+                if BlockSize[1] is not None:\r
                     self.FvInfFile.writelines("EFI_NUM_BLOCKS   = "  + \\r
                                           ' 0x%X' %BlockSize[1]    + \\r
                                           T_CHAR_LF)\r
 \r
-        if self.BsBaseAddress != None:\r
+        if self.BsBaseAddress is not None:\r
             self.FvInfFile.writelines('EFI_BOOT_DRIVER_BASE_ADDRESS = ' + \\r
                                        '0x%X' %self.BsBaseAddress)\r
-        if self.RtBaseAddress != None:\r
+        if self.RtBaseAddress is not None:\r
             self.FvInfFile.writelines('EFI_RUNTIME_DRIVER_BASE_ADDRESS = ' + \\r
                                       '0x%X' %self.RtBaseAddress)\r
         #\r
@@ -317,8 +317,8 @@ class FV (FvClassObject):
         self.FvInfFile.writelines("EFI_ERASE_POLARITY   = "       + \\r
                                           ' %s' %ErasePloarity    + \\r
                                           T_CHAR_LF)\r
-        if not (self.FvAttributeDict == None):\r
-            for FvAttribute in self.FvAttributeDict.keys() :\r
+        if not (self.FvAttributeDict is None):\r
+            for FvAttribute in self.FvAttributeDict:\r
                 if FvAttribute == "FvUsedSizeEnable":\r
                     if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', '1') :\r
                         self.UsedSizeEnable = True\r
@@ -328,7 +328,7 @@ class FV (FvClassObject):
                                           ' = '             + \\r
                                           self.FvAttributeDict[FvAttribute] + \\r
                                           T_CHAR_LF )\r
-        if self.FvAlignment != None:\r
+        if self.FvAlignment is not None:\r
             self.FvInfFile.writelines("EFI_FVB2_ALIGNMENT_"     + \\r
                                        self.FvAlignment.strip() + \\r
                                        " = TRUE"                + \\r
@@ -337,11 +337,10 @@ class FV (FvClassObject):
         #\r
         # Generate FV extension header file\r
         #\r
-        if self.FvNameGuid == None or self.FvNameGuid == '':\r
+        if not self.FvNameGuid:\r
             if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable:\r
                 GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName))\r
-        \r
-        if self.FvNameGuid <> None and self.FvNameGuid <> '':\r
+        else:\r
             TotalSize = 16 + 4\r
             Buffer = ''\r
             if self.UsedSizeEnable:\r
@@ -442,7 +441,7 @@ class FV (FvClassObject):
         # Add [Files]\r
         #\r
         self.FvInfFile.writelines("[files]" + T_CHAR_LF)\r
-        if VtfDict != None and self.UiFvName in VtfDict.keys():\r
+        if VtfDict is not None and self.UiFvName in VtfDict.keys():\r
             self.FvInfFile.writelines("EFI_FILE_NAME = "                   + \\r
                                        VtfDict.get(self.UiFvName)          + \\r
                                        T_CHAR_LF)\r