]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Eot/Parser.py
BaseTools: Use absolute import in Eot
[mirror_edk2.git] / BaseTools / Source / Python / Eot / Parser.py
index 6850c8d32a591b51cf02c2f630163e98df6bde6d..e01a9770befbc7d3340d79c41e153b67571184ae 100644 (file)
@@ -2,8 +2,8 @@
 # This file is used to define common parsing related functions used in parsing\r
 # Inf/Dsc/Makefile process\r
 #\r
-# Copyright (c) 2008 - 2010, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2008 - 2014, 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
 # Import Modules\r
 #\r
-import os, re\r
+from __future__ import absolute_import\r
+import Common.LongFilePathOs as os, re\r
 import Common.EdkLogger as EdkLogger\r
 from Common.DataType import *\r
 from CommonDataClass.DataClass import *\r
-from Common.String import CleanString, GetSplitValueList, ReplaceMacro\r
-import EotGlobalData\r
-from Common.Misc import sdict\r
+from Common.StringUtils import CleanString, GetSplitValueList, ReplaceMacro\r
+from . import EotGlobalData\r
+from Common.StringUtils import GetSplitList\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
 \r
 ## PreProcess() method\r
 #\r
@@ -49,11 +51,11 @@ def PreProcess(Filename, MergeMultipleLines = True, LineNo = -1):
     for Line in open(Filename, 'r'):\r
         Line = Line.strip()\r
         # Remove comment block\r
-        if Line.find(TAB_COMMENT_R8_START) > -1:\r
-            ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0]\r
+        if Line.find(TAB_COMMENT_EDK_START) > -1:\r
+            ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0]\r
             IsFindBlockComment = True\r
-        if Line.find(TAB_COMMENT_R8_END) > -1:\r
-            Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1]\r
+        if Line.find(TAB_COMMENT_EDK_END) > -1:\r
+            Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1]\r
             ReservedLine = ''\r
             IsFindBlockComment = False\r
         if IsFindBlockComment:\r
@@ -453,8 +455,7 @@ def SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode
         if NewRecordSet:\r
             NewRecord = NewRecordSet[0][0]\r
             VariableValueList = NewRecord.split('},')\r
-            if len(VariableValueList) > Index:\r
-                VariableValue = VariableValueList[Index]\r
+            for VariableValue in VariableValueList[Index:]:\r
                 NewVariableValueList = VariableValue.split(',')\r
                 if len(NewVariableValueList) > 1:\r
                     NewVariableValue = NewVariableValueList[1].strip()\r
@@ -622,7 +623,7 @@ def SearchProtocols(SqlCommand, Table, SourceFileID, SourceFileFullPath, ItemMod
 #  @param ItemMode: Mode of item\r
 #\r
 def SearchFunctionCalling(Table, SourceFileID, SourceFileFullPath, ItemType, ItemMode):\r
-    LibraryList = sdict()\r
+    LibraryList = {}\r
     Db = EotGlobalData.gDb.TblReport\r
     Parameters, ItemName, GuidName, GuidMacro, GuidValue, BelongsToFunction = [], '', '', '', '', ''\r
     if ItemType == 'Protocol' and ItemMode == 'Produced':\r
@@ -730,7 +731,7 @@ def GetParameter(Parameter, Index = 1):
 #  @return: The name of parameter\r
 #\r
 def GetParameterName(Parameter):\r
-    if type(Parameter) == type('') and Parameter.startswith('&'):\r
+    if isinstance(Parameter, type('')) and Parameter.startswith('&'):\r
         return Parameter[1:].replace('{', '').replace('}', '').replace('\r', '').replace('\n', '').strip()\r
     else:\r
         return Parameter.strip()\r