]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/BinToPcd: Open output file as text file
authorKinney, Michael D </o=Intel/ou=Americas01/cn=Workers/cn=Kinney, Michael D>
Fri, 3 Aug 2018 20:47:33 +0000 (04:47 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Mon, 6 Aug 2018 02:48:35 +0000 (10:48 +0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=1069

Undo changes from following commit:

https://github.com/tianocore/edk2/commit/83964ebc5e74549d6efc7134af19150a0b2079aa

Change the open mode for the output file from 'wb' to 'w' so the
output file is written as a text file and not a binary file.

This resolves the issue where the text file was not writable from
Python 3.x and also removes b'' from output file when the string
was encoded as a bytearray.

Cc: YanYan Sun <yanyan.sun@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Tested-by:YanYan Sun <yanyan.sun@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Scripts/BinToPcd.py

index 1495a36933c4ce5516aeb6bd48f4e8465da20fc3..316cc6117f56b58358e53948bbade4de87ed6085 100644 (file)
@@ -70,8 +70,7 @@ if __name__ == '__main__':
         #\r
         # Return a PCD value of the form '{0x01, 0x02, ...}' along with the PCD length in bytes\r
         #\r
-        PcdValue = '{' + ', '.join (['0x{Byte:02X}'.format (Byte = Item) for Item in Buffer]) + '}'\r
-        return PcdValue.encode (), len (Buffer)\r
+        return '{' + (', '.join (['0x{Byte:02X}'.format (Byte = Item) for Item in Buffer])) + '}', len (Buffer)\r
 \r
     #\r
     # Create command line argument parser object\r
@@ -81,7 +80,7 @@ if __name__ == '__main__':
                                       conflict_handler = 'resolve')\r
     parser.add_argument ("-i", "--input", dest = 'InputFile', type = argparse.FileType ('rb'), action='append', required = True,\r
                          help = "Input binary filename.  Multiple input files are combined into a single PCD.")\r
-    parser.add_argument ("-o", "--output", dest = 'OutputFile', type = argparse.FileType ('wb'),\r
+    parser.add_argument ("-o", "--output", dest = 'OutputFile', type = argparse.FileType ('w'),\r
                          help = "Output filename for PCD value or PCD statement")\r
     parser.add_argument ("-p", "--pcd", dest = 'PcdName', type = ValidatePcdName,\r
                          help = "Name of the PCD in the form <PcdTokenSpaceGuidCName>.<PcdCName>")\r