# Convert a binary file to a VOID* PCD value or DSC file VOID* PCD statement.\r
#\r
# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
\r
'''\r
BinToPcd\r
'''\r
+from __future__ import print_function\r
\r
import sys\r
import argparse\r
return Value\r
\r
def ValidatePcdName (Argument):\r
- if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['','']:\r
+ if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']:\r
Message = '{Argument} is not in the form <PcdTokenSpaceGuidCName>.<PcdCName>'.format (Argument = Argument)\r
raise argparse.ArgumentTypeError (Message)\r
return Argument\r
\r
def ValidateGuidName (Argument):\r
- if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['','']:\r
+ if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']:\r
Message = '{Argument} is not a valid GUID C name'.format (Argument = Argument)\r
raise argparse.ArgumentTypeError (Message)\r
return Argument\r
#\r
# If Xdr flag is not set, then concatenate all the data\r
#\r
- Buffer = b''.join (Buffer)\r
+ Buffer = bytearray (b''.join (Buffer))\r
#\r
# Return a PCD value of the form '{0x01, 0x02, ...}' along with the PCD length in bytes\r
#\r
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
- parser.add_argument ("-t", "--type", dest = 'PcdType', default = None, choices = ['VPD','HII'],\r
+ parser.add_argument ("-t", "--type", dest = 'PcdType', default = None, choices = ['VPD', 'HII'],\r
help = "PCD statement type (HII or VPD). Default is standard.")\r
parser.add_argument ("-m", "--max-size", dest = 'MaxSize', type = ValidateUnsignedInteger,\r
help = "Maximum size of the PCD. Ignored with --type HII.")\r