]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Library/CommentParsing.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Library / CommentParsing.py
index 285812c9c2f8465674e077449339333e8ff69480..7ba9830d34ac8b721d28db5d6814f8445aba77ec 100644 (file)
@@ -3,13 +3,7 @@
 #\r
 # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
-# This program and the accompanying materials are licensed and made available\r
-# under the terms and conditions of the BSD License which accompanies this\r
-# 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
@@ -74,7 +68,7 @@ def ParseHeaderCommentSection(CommentList, FileName = None, IsBinaryHeader = Fal
     # first find the last copyright line\r
     #\r
     Last = 0\r
-    for Index in xrange(len(CommentList)-1, 0, -1):\r
+    for Index in range(len(CommentList)-1, 0, -1):\r
         Line = CommentList[Index][0]\r
         if _IsCopyrightLine(Line):\r
             Last = Index\r
@@ -206,17 +200,15 @@ def ParsePcdErrorCode (Value = None, ContainerFile = None, LineNum = None):
             Base = 16\r
         else:\r
             Base = 10\r
-        ErrorCode = long(Value, Base)\r
+        ErrorCode = int(Value, Base)\r
         if ErrorCode > PCD_ERR_CODE_MAX_SIZE or ErrorCode < 0:\r
             Logger.Error('Parser',\r
                         FORMAT_NOT_SUPPORTED,\r
                         "The format %s of ErrorCode is not valid, should be UNIT32 type or long type" % Value,\r
                         File = ContainerFile,\r
                         Line = LineNum)\r
-        #\r
-        # To delete the tailing 'L'\r
-        #\r
-        return hex(ErrorCode)[:-1]\r
+        ErrorCode = '0x%x' % ErrorCode\r
+        return ErrorCode\r
     except ValueError as XStr:\r
         if XStr:\r
             pass\r
@@ -428,7 +420,7 @@ def _CheckListExpression(Expression):
 \r
     return IsValidListExpr(ListExpr)\r
 \r
-## _CheckExpreesion\r
+## _CheckExpression\r
 #\r
 # @param Expression: Pcd value expression\r
 #\r
@@ -478,11 +470,11 @@ def _ValidateCopyright(Line):
 \r
 def GenerateTokenList (Comment):\r
     #\r
-    # Tokenize Comment using '#' and ' ' as token seperators\r
+    # Tokenize Comment using '#' and ' ' as token separators\r
     #\r
-    RelplacedComment = None\r
-    while Comment != RelplacedComment:\r
-        RelplacedComment = Comment\r
+    ReplacedComment = None\r
+    while Comment != ReplacedComment:\r
+        ReplacedComment = Comment\r
         Comment = Comment.replace('##', '#').replace('  ', ' ').replace(' ', '#').strip('# ')\r
     return Comment.split('#')\r
 \r
@@ -540,13 +532,13 @@ def ParseComment (Comment, UsageTokens, TypeTokens, RemoveTokens, ParseVariable)
                 NumTokens = 1\r
 \r
     #\r
-    # Initialze HelpText to Comment.\r
+    # Initialize HelpText to Comment.\r
     # Content will be remove from HelpText as matching tokens are found\r
     #\r
     HelpText = Comment\r
 \r
     #\r
-    # Tokenize Comment using '#' and ' ' as token seperators\r
+    # Tokenize Comment using '#' and ' ' as token separators\r
     #\r
     List = GenerateTokenList (Comment)\r
 \r