]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FfsFileStatement.py
Revert BaseTools: PYTHON3 migration
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FfsFileStatement.py
index 3daf75b20584ff15db1dd548d5d9bd66f80d2985..4c35aac76a000e016d4386a2b5b995103c4006ed 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import absolute_import\r
 from . import Ffs\r
 from . import Rule\r
 import Common.LongFilePathOs as os\r
@@ -82,7 +83,7 @@ class FileStatement (FileStatementClassObject) :
         Dict.update(self.DefineVarDict)\r
         SectionAlignments = None\r
         if self.FvName is not None :\r
-            Buffer = BytesIO()\r
+            Buffer = BytesIO('')\r
             if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:\r
                 EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))\r
             Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())\r
@@ -99,7 +100,7 @@ class FileStatement (FileStatementClassObject) :
         elif self.FileName is not None:\r
             if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW':\r
                 if isinstance(self.FileName, list) and isinstance(self.SubAlignment, list) and len(self.FileName) == len(self.SubAlignment):\r
-                    FileContent = BytesIO()\r
+                    FileContent = ''\r
                     MaxAlignIndex = 0\r
                     MaxAlignValue = 1\r
                     for Index, File in enumerate(self.FileName):\r
@@ -115,15 +116,15 @@ class FileStatement (FileStatementClassObject) :
                         if AlignValue > MaxAlignValue:\r
                             MaxAlignIndex = Index\r
                             MaxAlignValue = AlignValue\r
-                        FileContent.write(Content)\r
-                        if len(FileContent.getvalue()) % AlignValue != 0:\r
+                        FileContent += Content\r
+                        if len(FileContent) % AlignValue != 0:\r
                             Size = AlignValue - len(FileContent) % AlignValue\r
                             for i in range(0, Size):\r
-                                FileContent.write(pack('B', 0xFF))\r
+                                FileContent += pack('B', 0xFF)\r
 \r
-                    if FileContent.getvalue() != b'':\r
+                    if FileContent:\r
                         OutputRAWFile = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid, self.NameGuid + '.raw')\r
-                        SaveFileOnChange(OutputRAWFile, FileContent.getvalue(), True)\r
+                        SaveFileOnChange(OutputRAWFile, FileContent, True)\r
                         self.FileName = OutputRAWFile\r
                         self.SubAlignment = self.SubAlignment[MaxAlignIndex]\r
 \r