X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FScripts%2FBinToPcd.py;h=3bc557b8412c4de624858868e6cb04460c59da7b;hb=b1357a40fcbe40ba6bdfa1579f96f8f5c7af35f9;hp=b907d3e5e0008e707955bca75aea28d02da2c357;hpb=0c805f4f8fe705d7c40c32afb2d09a26bc956ee1;p=mirror_edk2.git
diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
index b907d3e5e0..3bc557b841 100644
--- a/BaseTools/Scripts/BinToPcd.py
+++ b/BaseTools/Scripts/BinToPcd.py
@@ -2,18 +2,13 @@
# Convert a binary file to a VOID* PCD value or DSC file VOID* PCD statement.
#
# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
#
'''
BinToPcd
'''
+from __future__ import print_function
import sys
import argparse
@@ -40,13 +35,13 @@ if __name__ == '__main__':
return Value
def ValidatePcdName (Argument):
- if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['','']:
+ if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']:
Message = '{Argument} is not in the form .'.format (Argument = Argument)
raise argparse.ArgumentTypeError (Message)
return Argument
def ValidateGuidName (Argument):
- if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['','']:
+ if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']:
Message = '{Argument} is not a valid GUID C name'.format (Argument = Argument)
raise argparse.ArgumentTypeError (Message)
return Argument
@@ -65,7 +60,7 @@ if __name__ == '__main__':
#
# If Xdr flag is not set, then concatenate all the data
#
- Buffer = b''.join (Buffer)
+ Buffer = bytearray (b''.join (Buffer))
#
# Return a PCD value of the form '{0x01, 0x02, ...}' along with the PCD length in bytes
#
@@ -79,11 +74,11 @@ if __name__ == '__main__':
conflict_handler = 'resolve')
parser.add_argument ("-i", "--input", dest = 'InputFile', type = argparse.FileType ('rb'), action='append', required = True,
help = "Input binary filename. Multiple input files are combined into a single PCD.")
- parser.add_argument ("-o", "--output", dest = 'OutputFile', type = argparse.FileType ('wb'),
+ parser.add_argument ("-o", "--output", dest = 'OutputFile', type = argparse.FileType ('w'),
help = "Output filename for PCD value or PCD statement")
parser.add_argument ("-p", "--pcd", dest = 'PcdName', type = ValidatePcdName,
help = "Name of the PCD in the form .")
- parser.add_argument ("-t", "--type", dest = 'PcdType', default = None, choices = ['VPD','HII'],
+ parser.add_argument ("-t", "--type", dest = 'PcdType', default = None, choices = ['VPD', 'HII'],
help = "PCD statement type (HII or VPD). Default is standard.")
parser.add_argument ("-m", "--max-size", dest = 'MaxSize', type = ValidateUnsignedInteger,
help = "Maximum size of the PCD. Ignored with --type HII.")