diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-11-09 04:32:08 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-11-09 04:32:08 +0000 |
commit | d40b2ee60ef161044bcaf05a8b36aa60eac633cc (patch) | |
tree | 1a74bea930f47fe2bb8f9d07d0151c6c7d9adac3 /BaseTools/Source/Python/Common | |
parent | 080681592188f45228616983f9e1610ab9e86615 (diff) | |
download | edk2-platforms-d40b2ee60ef161044bcaf05a8b36aa60eac633cc.tar.xz |
Sync BaseTool trunk (version r2397) into EDKII BaseTools. The change mainly includes
1. Fix the issue that root directory of disk can’t be used as WORKSPACE.
2. Update AutoGen code style to pass C++ compiler.
Signed-off-by: lgao4
Reviewed-by: jsu1
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12676 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Common')
-rw-r--r-- | BaseTools/Source/Python/Common/BuildVersion.py | 2 | ||||
-rw-r--r-- | BaseTools/Source/Python/Common/DecClassObject.py | 88 | ||||
-rw-r--r-- | BaseTools/Source/Python/Common/DecClassObjectLight.py | 106 | ||||
-rw-r--r-- | BaseTools/Source/Python/Common/DscClassObject.py | 66 | ||||
-rw-r--r-- | BaseTools/Source/Python/Common/InfClassObject.py | 18 | ||||
-rw-r--r-- | BaseTools/Source/Python/Common/InfClassObjectLight.py | 146 | ||||
-rw-r--r-- | BaseTools/Source/Python/Common/String.py | 54 |
7 files changed, 240 insertions, 240 deletions
diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py index 82597c0945..97c1094205 100644 --- a/BaseTools/Source/Python/Common/BuildVersion.py +++ b/BaseTools/Source/Python/Common/BuildVersion.py @@ -1,3 +1,3 @@ #This file is for build version number auto generation
#
-gBUILD_VERSION = "Build 2386"
+gBUILD_VERSION = "Build 2396"
diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/Source/Python/Common/DecClassObject.py index 18816806f2..5b39bcd4ce 100644 --- a/BaseTools/Source/Python/Common/DecClassObject.py +++ b/BaseTools/Source/Python/Common/DecClassObject.py @@ -82,14 +82,14 @@ class DecObject(object): # @var KeyList: To store value for KeyList, a list for all Keys used in Dec
#
class Dec(DecObject):
- def __init__(self, Filename = None, IsToDatabase = False, IsToPackage = False, WorkspaceDir = None, Database = None, SupArchList = DataType.ARCH_LIST):
+ def __init__(self, Filename=None, IsToDatabase=False, IsToPackage=False, WorkspaceDir=None, Database=None, SupArchList=DataType.ARCH_LIST):
self.Identification = Identification()
self.Package = PackageClass()
self.UserExtensions = ''
self.WorkspaceDir = WorkspaceDir
self.SupArchList = SupArchList
self.IsToDatabase = IsToDatabase
-
+
self.Cur = Database.Cur
self.TblFile = Database.TblFile
self.TblDec = Database.TblDec
@@ -104,26 +104,26 @@ class Dec(DecObject): # Upper all KEYs to ignore case sensitive when parsing
#
self.KeyList = map(lambda c: c.upper(), self.KeyList)
-
+
#
# Init RecordSet
#
- self.RecordSet = {}
+ self.RecordSet = {}
for Key in self.KeyList:
self.RecordSet[Section[Key]] = []
-
+
#
# Load Dec file if filename is not None
#
if Filename != None:
self.LoadDecFile(Filename)
-
+
#
# Transfer to Package Object if IsToPackage is True
#
if IsToPackage:
self.DecToPackage()
-
+
## Load Dec file
#
# Load the file if it exists
@@ -138,20 +138,20 @@ class Dec(DecObject): self.Identification.FileFullPath = Filename
(self.Identification.FileRelativePath, self.Identification.FileName) = os.path.split(Filename)
self.FileID = self.TblFile.InsertFile(Filename, MODEL_FILE_DEC)
-
+
#
# Init DecTable
#
#self.TblDec.Table = "Dec%s" % self.FileID
#self.TblDec.Create()
-
+
#
# Init common datas
#
IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \
[], [], TAB_UNKNOWN, [], [], []
LineNo = 0
-
+
#
# Parse file content
#
@@ -163,10 +163,10 @@ class Dec(DecObject): # Remove comment block
#
if Line.find(TAB_COMMENT_EDK_START) > -1:
- ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]
+ ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0]
IsFindBlockComment = True
if Line.find(TAB_COMMENT_EDK_END) > -1:
- Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]
+ Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1]
ReservedLine = ''
IsFindBlockComment = False
if IsFindBlockComment:
@@ -178,7 +178,7 @@ class Dec(DecObject): Line = CleanString(Line)
if Line == '':
continue
-
+
#
# Find a new section tab
# First insert previous section items
@@ -197,7 +197,7 @@ class Dec(DecObject): SectionItemList = []
ArchList = []
ThirdList = []
-
+
CurrentSection = ''
LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
for Item in LineList:
@@ -206,7 +206,7 @@ class Dec(DecObject): CurrentSection = ItemList[0]
else:
if CurrentSection != ItemList[0]:
- EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
if CurrentSection.upper() not in self.KeyList:
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
ItemList.append('')
@@ -215,18 +215,18 @@ class Dec(DecObject): RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
else:
if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
- EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
ArchList.append(ItemList[1].upper())
ThirdList.append(ItemList[2])
continue
-
+
#
# Not in any defined section
#
if CurrentSection == TAB_UNKNOWN:
ErrorMsg = "%s is not in any defined section" % Line
- EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
#
# Add a section item
@@ -234,13 +234,13 @@ class Dec(DecObject): SectionItemList.append([Line, LineNo])
# End of parse
#End of For
-
+
#
# Insert items data of last section
#
Model = Section[CurrentSection.upper()]
InsertSectionItemsIntoDatabase(self.TblDec, self.FileID, Filename, Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList, self.RecordSet)
-
+
#
# Replace all DEFINE macros with its actual values
#
@@ -255,12 +255,12 @@ class Dec(DecObject): # Init global information for the file
#
ContainerFile = self.Identification.FileFullPath
-
+
#
# Generate Package Header
#
self.GenPackageHeader(ContainerFile)
-
+
#
# Generate Includes
#
@@ -280,17 +280,17 @@ class Dec(DecObject): # Generate Ppis
#
self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile)
-
+
#
# Generate LibraryClasses
#
self.GenLibraryClasses(ContainerFile)
-
+
#
# Generate Pcds
#
self.GenPcds(ContainerFile)
-
+
## Get Package Header
#
# Gen Package Header of Dec as <Key> = <Value>
@@ -311,22 +311,22 @@ class Dec(DecObject): SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
where ID = %s""" % (self.TblDec.Table, ConvertToSqlString2(Value1), ConvertToSqlString2(Value2), ID)
self.TblDec.Exec(SqlCommand)
-
+
#
# Get detailed information
#
for Arch in self.SupArchList:
PackageHeader = PackageHeaderClass()
-
+
PackageHeader.Name = QueryDefinesItem(self.TblDec, TAB_DEC_DEFINES_PACKAGE_NAME, Arch, self.FileID)[0]
PackageHeader.Guid = QueryDefinesItem(self.TblDec, TAB_DEC_DEFINES_PACKAGE_GUID, Arch, self.FileID)[0]
PackageHeader.Version = QueryDefinesItem(self.TblDec, TAB_DEC_DEFINES_PACKAGE_VERSION, Arch, self.FileID)[0]
PackageHeader.FileName = self.Identification.FileName
PackageHeader.FullPath = self.Identification.FileFullPath
PackageHeader.DecSpecification = QueryDefinesItem(self.TblDec, TAB_DEC_DEFINES_DEC_SPECIFICATION, Arch, self.FileID)[0]
-
+
self.Package.Header[Arch] = PackageHeader
-
+
## GenIncludes
#
# Gen Includes of Dec
@@ -341,7 +341,7 @@ class Dec(DecObject): # Get all Includes
#
RecordSet = self.RecordSet[MODEL_EFI_INCLUDE]
-
+
#
# Go through each arch
#
@@ -355,7 +355,7 @@ class Dec(DecObject): Include.FilePath = NormPath(Key)
Include.SupArchList = Includes[Key]
self.Package.Includes.append(Include)
-
+
## GenPpis
#
# Gen Ppis of Dec
@@ -370,7 +370,7 @@ class Dec(DecObject): # Get all Items
#
RecordSet = self.RecordSet[Section[Type.upper()]]
-
+
#
# Go through each arch
#
@@ -383,7 +383,7 @@ class Dec(DecObject): SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
where ID = %s""" % (self.TblDec.Table, ConvertToSqlString2(Name), ConvertToSqlString2(Value), Record[3])
self.TblDec.Exec(SqlCommand)
-
+
ListMember = None
if Type == TAB_GUIDS:
ListMember = self.Package.GuidDeclarations
@@ -391,15 +391,15 @@ class Dec(DecObject): ListMember = self.Package.ProtocolDeclarations
elif Type == TAB_PPIS:
ListMember = self.Package.PpiDeclarations
-
+
for Key in Lists.keys():
ListClass = GuidProtocolPpiCommonClass()
ListClass.CName = Key[0]
ListClass.Guid = Key[1]
ListClass.SupArchList = Lists[Key]
ListMember.append(ListClass)
-
-
+
+
## GenLibraryClasses
#
# Gen LibraryClasses of Dec
@@ -414,7 +414,7 @@ class Dec(DecObject): # Get all Guids
#
RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS]
-
+
#
# Go through each arch
#
@@ -432,7 +432,7 @@ class Dec(DecObject): where ID = %s""" % (self.TblDec.Table, ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), SUP_MODULE_LIST_STRING, Record[3])
self.TblDec.Exec(SqlCommand)
-
+
for Key in LibraryClasses.keys():
LibraryClass = LibraryClassClass()
LibraryClass.LibraryClass = Key[0]
@@ -440,7 +440,7 @@ class Dec(DecObject): LibraryClass.SupModuleList = SUP_MODULE_LIST
LibraryClass.SupArchList = LibraryClasses[Key]
self.Package.LibraryClassDeclarations.append(LibraryClass)
-
+
## GenPcds
#
# Gen Pcds of Dec
@@ -460,7 +460,7 @@ class Dec(DecObject): RecordSet3 = self.RecordSet[MODEL_PCD_FEATURE_FLAG]
RecordSet4 = self.RecordSet[MODEL_PCD_DYNAMIC_EX]
RecordSet5 = self.RecordSet[MODEL_PCD_DYNAMIC]
-
+
#
# Go through each arch
#
@@ -508,7 +508,7 @@ class Dec(DecObject): Pcd.ItemType = Key[5]
Pcd.SupArchList = Pcds[Key]
self.Package.PcdDeclarations.append(Pcd)
-
+
## Show detailed information of Package
#
# Print all members and their values of Package class
@@ -550,14 +550,14 @@ class Dec(DecObject): if __name__ == '__main__':
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.DEBUG_0)
-
+
W = os.getenv('WORKSPACE')
F = os.path.join(W, 'Nt32Pkg/Nt32Pkg.dec')
Db = Database.Database('Dec.db')
Db.InitDatabase()
-
+
P = Dec(os.path.normpath(F), True, True, W, Db)
P.ShowPackage()
-
+
Db.Close()
diff --git a/BaseTools/Source/Python/Common/DecClassObjectLight.py b/BaseTools/Source/Python/Common/DecClassObjectLight.py index cba88b64f2..7fb41a2359 100644 --- a/BaseTools/Source/Python/Common/DecClassObjectLight.py +++ b/BaseTools/Source/Python/Common/DecClassObjectLight.py @@ -75,7 +75,7 @@ class DecObject(object): # @var KeyList: To store value for KeyList, a list for all Keys used in Dec
#
class Dec(DecObject):
- def __init__(self, Filename = None, IsToPackage = False, WorkspaceDir = None, AllGuidVersionDict = None, SupArchList = DataType.ARCH_LIST):
+ def __init__(self, Filename=None, IsToPackage=False, WorkspaceDir=None, AllGuidVersionDict=None, SupArchList=DataType.ARCH_LIST):
self.Identification = IdentificationClass()
self.Package = PackageClass()
self.UserExtensions = ''
@@ -92,23 +92,23 @@ class Dec(DecObject): ]
# Upper all KEYs to ignore case sensitive when parsing
self.KeyList = map(lambda c: c.upper(), self.KeyList)
-
+
# Init RecordSet
- self.RecordSet = {}
+ self.RecordSet = {}
for Key in self.KeyList:
self.RecordSet[Section[Key]] = []
-
+
# Init Comment
self.SectionHeaderCommentDict = {}
-
+
# Load Dec file if filename is not None
if Filename != None:
self.LoadDecFile(Filename)
-
+
# Transfer to Package Object if IsToPackage is True
if IsToPackage:
self.DecToPackage()
-
+
## Load Dec file
#
# Load the file if it exists
@@ -121,13 +121,13 @@ class Dec(DecObject): self.Identification.FullPath = Filename
(self.Identification.RelaPath, self.Identification.FileName) = os.path.split(Filename)
if self.Identification.FullPath.find(self.WorkspaceDir) > -1:
- self.Identification.PackagePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:])
-
+ self.Identification.PackagePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:])
+
# Init common datas
IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \
[], [], TAB_UNKNOWN, [], [], []
LineNo = 0
-
+
# Parse file content
IsFindBlockComment = False
ReservedLine = ''
@@ -136,7 +136,7 @@ class Dec(DecObject): LineNo = LineNo + 1
# Remove comment block
if Line.find(TAB_COMMENT_EDK_START) > -1:
- ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]
+ ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0]
if ReservedLine.strip().startswith(TAB_COMMENT_SPLIT):
Comment = Comment + Line.strip() + '\n'
ReservedLine = ''
@@ -147,7 +147,7 @@ class Dec(DecObject): continue
if Line.find(TAB_COMMENT_EDK_END) > -1:
Comment = Comment + Line[:Line.find(TAB_COMMENT_EDK_END) + len(TAB_COMMENT_EDK_END)] + '\n'
- Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]
+ Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1]
ReservedLine = ''
IsFindBlockComment = False
if IsFindBlockComment:
@@ -160,7 +160,7 @@ class Dec(DecObject): Line = CleanString(Line)
if Line == '':
continue
-
+
## Find a new section tab
# First insert previous section items
# And then parse the content of the new section
@@ -173,7 +173,7 @@ class Dec(DecObject): SectionItemList = []
ArchList = []
ThirdList = []
-
+
CurrentSection = ''
LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
for Item in LineList:
@@ -182,7 +182,7 @@ class Dec(DecObject): CurrentSection = ItemList[0]
else:
if CurrentSection != ItemList[0]:
- EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
if CurrentSection.upper() not in self.KeyList:
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
ItemList.append('')
@@ -191,28 +191,28 @@ class Dec(DecObject): RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
else:
if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
- EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
ArchList.append(ItemList[1].upper())
ThirdList.append(ItemList[2])
-
+
if Comment:
if Comment.endswith('\n'):
Comment = Comment[:len(Comment) - len('\n')]
self.SectionHeaderCommentDict[Section[CurrentSection.upper()]] = Comment
Comment = ''
continue
-
+
# Not in any defined section
if CurrentSection == TAB_UNKNOWN:
ErrorMsg = "%s is not in any defined section" % Line
- EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
# Add a section item
SectionItemList.append([Line, LineNo, Comment])
Comment = ''
# End of parse
#End of For
-
+
#
# Insert items data of last section
#
@@ -229,7 +229,7 @@ class Dec(DecObject): SectionHeaderCommentDict = {}
if Package == None:
return Dec
-
+
PackageHeader = Package.PackageHeader
TmpList = []
if PackageHeader.Name:
@@ -243,30 +243,30 @@ class Dec(DecObject): if Package.UserExtensions != None:
for Item in Package.UserExtensions.Defines:
TmpList.append(Item)
- DecList['Defines'] =TmpList
+ DecList['Defines'] = TmpList
if PackageHeader.Description != '':
SectionHeaderCommentDict['Defines'] = PackageHeader.Description
-
+
for Item in Package.Includes:
Key = 'Includes.' + Item.SupArchList
Value = Item.FilePath
GenMetaDatSectionItem(Key, Value, DecList)
-
+
for Item in Package.GuidDeclarations:
Key = 'Guids.' + Item.SupArchList
Value = Item.CName + '=' + Item.Guid
GenMetaDatSectionItem(Key, Value, DecList)
-
+
for Item in Package.ProtocolDeclarations:
Key = 'Protocols.' + Item.SupArchList
Value = Item.CName + '=' + Item.Guid
GenMetaDatSectionItem(Key, Value, DecList)
-
+
for Item in Package.PpiDeclarations:
Key = 'Ppis.' + Item.SupArchList
Value = Item.CName + '=' + Item.Guid
GenMetaDatSectionItem(Key, Value, DecList)
-
+
for Item in Package.LibraryClassDeclarations:
Key = 'LibraryClasses.' + Item.SupArchList
Value = Item.LibraryClass + '|' + Item.RecommendedInstance
@@ -297,7 +297,7 @@ class Dec(DecObject): else:
Dec = Dec + ' ' + Value + '\n'
Dec = Dec + '\n'
-
+
return Dec
## Transfer to Package Object
@@ -307,10 +307,10 @@ class Dec(DecObject): def DecToPackage(self):
# Init global information for the file
ContainerFile = self.Identification.FullPath
-
+
# Generate Package Header
self.GenPackageHeader(ContainerFile)
-
+
# Generate Includes
# Only for Edk
self.GenIncludes(ContainerFile)
@@ -323,16 +323,16 @@ class Dec(DecObject): # Generate Ppis
self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile)
-
+
# Generate LibraryClasses
self.GenLibraryClasses(ContainerFile)
-
+
# Generate Pcds
self.GenPcds(ContainerFile)
-
+
# Init MiscFiles
self.GenMiscFiles(ContainerFile)
-
+
## GenMiscFiles
#
def GenMiscFiles(self, ContainerFile):
@@ -343,7 +343,7 @@ class Dec(DecObject): File.Filename = Item
MiscFiles.Files.append(File)
self.Package.MiscFiles = MiscFiles
-
+
## Get Package Header
#
# Gen Package Header of Dec as <Key> = <Value>
@@ -375,23 +375,23 @@ class Dec(DecObject): PackageHeader.DecSpecification = Value
else:
OtherDefines.append(Record[0])
-
+
PackageHeader.FileName = self.Identification.FileName
PackageHeader.FullPath = self.Identification.FullPath
PackageHeader.RelaPath = self.Identification.RelaPath
PackageHeader.PackagePath = self.Identification.PackagePath
PackageHeader.ModulePath = self.Identification.ModulePath
PackageHeader.CombinePath = os.path.normpath(os.path.join(PackageHeader.PackagePath, PackageHeader.ModulePath, PackageHeader.FileName))
-
+
if MODEL_META_DATA_HEADER in self.SectionHeaderCommentDict:
PackageHeader.Description = self.SectionHeaderCommentDict[MODEL_META_DATA_HEADER]
-
+
self.Package.PackageHeader = PackageHeader
UE = UserExtensionsClass()
UE.Defines = OtherDefines
self.Package.UserExtensions = UE
-
-
+
+
## GenIncludes
#
# Gen Includes of Dec
@@ -403,7 +403,7 @@ class Dec(DecObject): Includes = {}
# Get all Includes
RecordSet = self.RecordSet[MODEL_EFI_INCLUDE]
-
+
# Go through each arch
for Record in RecordSet:
Arch = Record[1]
@@ -412,7 +412,7 @@ class Dec(DecObject): Include.FilePath = NormPath(Key)
Include.SupArchList = Arch
self.Package.Includes.append(Include)
-
+
## GenPpis
#
# Gen Ppis of Dec
@@ -425,12 +425,12 @@ class Dec(DecObject): Lists = {}
# Get all Items
RecordSet = self.RecordSet[Section[Type.upper()]]
-
+
# Go through each arch
for Record in RecordSet:
Arch = Record[1]
(Name, Value) = GetGuidsProtocolsPpisOfDec(Record[0], Type, ContainerFile, Record[2])
-
+
ListMember = None
if Type == TAB_GUIDS:
ListMember = self.Package.GuidDeclarations
@@ -438,13 +438,13 @@ class Dec(DecObject): ListMember = self.Package.ProtocolDeclarations
elif Type == TAB_PPIS:
ListMember = self.Package.PpiDeclarations
-
+
ListClass = GuidProtocolPpiCommonClass()
ListClass.CName = Name
ListClass.Guid = Value
ListClass.SupArchList = Arch
ListMember.append(ListClass)
-
+
## GenLibraryClasses
#
# Gen LibraryClasses of Dec
@@ -457,7 +457,7 @@ class Dec(DecObject): LibraryClasses = {}
# Get all Guids
RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS]
-
+
# Go through each arch
for Record in RecordSet:
Arch = Record[1]
@@ -469,7 +469,7 @@ class Dec(DecObject): LibraryClass.RecommendedInstance = NormPath(List[1])
LibraryClass.SupArchList = Arch
self.Package.LibraryClassDeclarations.append(LibraryClass)
-
+
def AddPcd(self, CName, Token, TokenSpaceGuidCName, DatumType, DefaultValue, ItemType, Arch):
Pcd = CommonClass.PcdClass()
Pcd.CName = CName
@@ -480,7 +480,7 @@ class Dec(DecObject): Pcd.ItemType = ItemType
Pcd.SupArchList = Arch
self.Package.PcdDeclarations.append(Pcd)
-
+
## GenPcds
#
# Gen Pcds of Dec
@@ -498,7 +498,7 @@ class Dec(DecObject): RecordSet3 = self.RecordSet[MODEL_PCD_FEATURE_FLAG]
RecordSet4 = self.RecordSet[MODEL_PCD_DYNAMIC_EX]
RecordSet5 = self.RecordSet[MODEL_PCD_DYNAMIC]
-
+
# Go through each pcd
for Record in RecordSet1:
Arch = Record[1]
@@ -520,7 +520,7 @@ class Dec(DecObject): Arch = Record[1]
(TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC, ContainerFile, Record[2])
self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch)
-
+
## Show detailed information of Package
#
# Print all members and their values of Package class
@@ -533,7 +533,7 @@ class Dec(DecObject): print 'PackagePath =', M.PackageHeader.PackagePath
print 'ModulePath =', M.PackageHeader.ModulePath
print 'CombinePath =', M.PackageHeader.CombinePath
-
+
print 'BaseName =', M.PackageHeader.Name
print 'Guid =', M.PackageHeader.Guid
print 'Version =', M.PackageHeader.Version
@@ -571,7 +571,7 @@ class Dec(DecObject): if __name__ == '__main__':
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.QUIET)
-
+
W = os.getenv('WORKSPACE')
F = os.path.join(W, 'MdeModulePkg/MdeModulePkg.dec')
diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py index 428f1686b6..3d06288e9a 100644 --- a/BaseTools/Source/Python/Common/DscClassObject.py +++ b/BaseTools/Source/Python/Common/DscClassObject.py @@ -91,7 +91,7 @@ class DscObject(object): class Dsc(DscObject):
_NullClassIndex = 0
- def __init__(self, Filename = None, IsToDatabase = False, IsToPlatform = False, WorkspaceDir = None, Database = None):
+ def __init__(self, Filename=None, IsToDatabase=False, IsToPlatform=False, WorkspaceDir=None, Database=None):
self.Identification = Identification()
self.Platform = PlatformClass()
self.UserExtensions = ''
@@ -460,7 +460,7 @@ class Dsc(DscObject): # @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
- def GenPcds(self, Type = '', ContainerFile = ''):
+ def GenPcds(self, Type='', ContainerFile=''):
Pcds = {}
if Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:
Model = MODEL_PCD_PATCHABLE_IN_MODULE
@@ -512,7 +512,7 @@ class Dsc(DscObject): # @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
- def GenFeatureFlagPcds(self, Type = '', ContainerFile = ''):
+ def GenFeatureFlagPcds(self, Type='', ContainerFile=''):
Pcds = {}
if Type == DataType.TAB_PCDS_FEATURE_FLAG:
Model = MODEL_PCD_FEATURE_FLAG
@@ -562,7 +562,7 @@ class Dsc(DscObject): # @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
- def GenDynamicDefaultPcds(self, Type = '', ContainerFile = ''):
+ def GenDynamicDefaultPcds(self, Type='', ContainerFile=''):
Pcds = {}
SkuInfoList = {}
if Type == DataType.TAB_PCDS_DYNAMIC_DEFAULT:
@@ -594,20 +594,20 @@ class Dsc(DscObject): if CleanString(NewItem) == '':
continue
(K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(NewItem, Type, Filename, -1)
- MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, IncludeFile[4]), Arch)
+ MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, IncludeFile[4]), Arch)
self.PcdToken[Record[3]] = (K2, K1)
for Record in RecordSet:
if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
(K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(Record[0], Type, ContainerFile, Record[2])
- MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, Record[4]), Arch)
+ MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, Record[4]), Arch)
self.PcdToken[Record[3]] = (K2, K1)
for Key in Pcds:
(Status, SkuInfoList) = self.GenSkuInfoList(Key[6], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2])
if Status == False:
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
- EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError=EdkLogger.IsRaiseError)
Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], SkuInfoList, [])
Pcd.SupArchList = Pcds[Key]
self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
@@ -619,7 +619,7 @@ class Dsc(DscObject): # @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
- def GenDynamicHiiPcds(self, Type = '', ContainerFile = ''):
+ def GenDynamicHiiPcds(self, Type='', ContainerFile=''):
Pcds = {}
SkuInfoList = {}
if Type == DataType.TAB_PCDS_DYNAMIC_HII:
@@ -651,20 +651,20 @@ class Dsc(DscObject): if CleanString(NewItem) == '':
continue
(K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(NewItem, Type, Filename, -1)
- MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, IncludeFile[4]), Arch)
+ MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, IncludeFile[4]), Arch)
self.PcdToken[Record[3]] = (K2, K1)
for Record in RecordSet:
if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
(K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(Record[0], Type, ContainerFile, Record[2])
- MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, Record[4]), Arch)
+ MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, Record[4]), Arch)
self.PcdToken[Record[3]] = (K2, K1)
for Key in Pcds:
(Status, SkuInfoList) = self.GenSkuInfoList(Key[8], self.Platform.SkuInfos.SkuInfoList, Key[2], Key[3], Key[4], Key[5], '', '')
if Status == False:
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
- EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError=EdkLogger.IsRaiseError)
Pcd = PcdClass(Key[0], '', Key[1], '', Key[6], Key[5], Key[7], [], SkuInfoList, [])
Pcd.SupArchList = Pcds[Key]
self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
@@ -676,7 +676,7 @@ class Dsc(DscObject): # @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
- def GenDynamicVpdPcds(self, Type = '', ContainerFile = ''):
+ def GenDynamicVpdPcds(self, Type='', ContainerFile=''):
Pcds = {}
SkuInfoList = {}
if Type == DataType.TAB_PCDS_DYNAMIC_VPD:
@@ -708,20 +708,20 @@ class Dsc(DscObject): if CleanString(NewItem) == '':
continue
(K1, K2, K3, K4, K5) = GetDynamicVpdPcd(NewItem, Type, Filename, -1)
- MergeArches(Pcds, (K1, K2, K3, K4, K5, IncludeFile[4]), Arch)
+ MergeArches(Pcds, (K1, K2, K3, K4, K5, IncludeFile[4]), Arch)
self.PcdToken[Record[3]] = (K2, K1)
for Record in RecordSet:
if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
(K1, K2, K3, K4, K5) = GetDynamicVpdPcd(Record[0], Type, ContainerFile, Record[2])
- MergeArches(Pcds, (K1, K2, K3, K4, K5, Record[4]), Arch)
+ MergeArches(Pcds, (K1, K2, K3, K4, K5, Record[4]), Arch)
self.PcdToken[Record[3]] = (K2, K1)
for Key in Pcds:
(Status, SkuInfoList) = self.GenSkuInfoList(Key[5], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '')
if Status == False:
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
- EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError=EdkLogger.IsRaiseError)
Pcd = PcdClass(Key[0], '', Key[1], '', Key[3], '', Key[4], [], SkuInfoList, [])
Pcd.SupArchList = Pcds[Key]
self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
@@ -769,7 +769,7 @@ class Dsc(DscObject): SubLibSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, Record[3], self.FileID)
for SubLib in SubLibSet:
- Lib.append(TAB_VALUE_SPLIT.join([SubLib[0],SubLib[4]]))
+ Lib.append(TAB_VALUE_SPLIT.join([SubLib[0], SubLib[4]]))
SubBoSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_BUILD_OPTION, Record[3], self.FileID)
for SubBo in SubBoSet:
@@ -806,7 +806,7 @@ class Dsc(DscObject): #
# @retval PlatformModuleClass() A instance for PlatformModuleClass
#
- def GenComponent(self, Item, ContainerFile, LineNo = -1):
+ def GenComponent(self, Item, ContainerFile, LineNo= -1):
(InfFilename, ExecFilename) = GetExec(Item[0])
LibraryClasses = Item[1]
BuildOptions = Item[2]
@@ -894,7 +894,7 @@ class Dsc(DscObject): # @retval (False, SkuName) Not found in section SkuId Dsc file
# @retval (True, SkuInfoList) Found in section SkuId of Dsc file
#
- def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName = '', VariableGuid = '', VariableOffset = '', HiiDefaultValue = '', VpdOffset = '', DefaultValue = ''):
+ def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName='', VariableGuid='', VariableOffset='', HiiDefaultValue='', VpdOffset='', DefaultValue=''):
SkuNameList = GetSplitValueList(SkuNameList)
if SkuNameList == None or SkuNameList == [] or SkuNameList == ['']:
SkuNameList = ['DEFAULT']
@@ -964,7 +964,7 @@ class Dsc(DscObject): (Value1, Value2, Value3, Model, StartColumn, EndColumn, Enabled) = ('', '', '', -1, -1, -1, 0)
if IfDefList == []:
ErrorMsg = 'Not suited conditional statement in file %s' % Filename
- EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename, RaiseError=EdkLogger.IsRaiseError)
else:
#
# Get New Dsc item ID
@@ -1046,10 +1046,10 @@ class Dsc(DscObject): # Remove comment block
#
if Line.find(TAB_COMMENT_EDK_START) > -1:
- ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]
+ ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0]
IsFindBlockComment = True
if Line.find(TAB_COMMENT_EDK_END) > -1:
- Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]
+ Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1]
ReservedLine = ''
IsFindBlockComment = False
if IsFindBlockComment:
@@ -1087,7 +1087,7 @@ class Dsc(DscObject): CurrentSection = ItemList[0]
else:
if CurrentSection != ItemList[0]:
- EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
if CurrentSection.upper() not in self.KeyList:
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
CurrentSection = TAB_UNKNOWN
@@ -1098,7 +1098,7 @@ class Dsc(DscObject): RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
else:
if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
- EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
ArchList.append(ItemList[1].upper())
ThirdList.append(ItemList[2])
@@ -1109,7 +1109,7 @@ class Dsc(DscObject): #
if CurrentSection == TAB_UNKNOWN:
ErrorMsg = "%s is not in any defined section" % Line
- EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
#
# Add a section item
@@ -1161,7 +1161,7 @@ class Dsc(DscObject): MODEL_META_DATA_DEFINE)
RecordSet = self.TblDsc.Exec(SqlCommand)
for Record in RecordSet:
- SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[0], Record[1])
+ SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" % (self.TblDsc.Table, Record[0], Record[1])
self.TblDsc.Exec(SqlCommand)
#
@@ -1185,8 +1185,8 @@ class Dsc(DscObject): MODEL_META_DATA_DEFINE)
RecordSet = self.TblDsc.Exec(SqlCommand)
for Record in RecordSet:
- SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[0], Record[1])
- EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)
+ SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" % (self.TblDsc.Table, Record[0], Record[1])
+ EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
self.Cur.execute(SqlCommand)
#
@@ -1210,13 +1210,13 @@ class Dsc(DscObject): for Record in RecordSet:
if Record[0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_IF:
if not self.Compare(Record[6], Record[2], Record[3]):
- SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[4], Record[5])
+ SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" % (self.TblDsc.Table, Record[4], Record[5])
self.TblDsc.Exec(SqlCommand)
else:
DisabledList.append(Record[1])
continue
if Record[0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE and Record[1] in DisabledList:
- SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[4], Record[5])
+ SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" % (self.TblDsc.Table, Record[4], Record[5])
self.TblDsc.Exec(SqlCommand)
## Compare
@@ -1227,7 +1227,7 @@ class Dsc(DscObject): # @param Value2:
#
def Compare(self, Value1, CompareType, Value2):
- Command = """Value1 %s Value2""" %CompareType
+ Command = """Value1 %s Value2""" % CompareType
return eval(Command)
## First time to insert records to database
@@ -1259,7 +1259,7 @@ class Dsc(DscObject): LineValue, StartLine, EndLine = SectionItem[0], SectionItem[1], SectionItem[1]
- EdkLogger.debug(4, "Parsing %s ..." %LineValue)
+ EdkLogger.debug(4, "Parsing %s ..." % LineValue)
#
# Parse '!ifdef'
#
@@ -1337,10 +1337,10 @@ class Dsc(DscObject): Components = []
GetComponent(SectionItemList, Components)
for Component in Components:
- EdkLogger.debug(4, "Parsing component %s ..." %Component)
+ EdkLogger.debug(4, "Parsing component %s ..." % Component)
DscItmeID = self.TblDsc.Insert(MODEL_META_DATA_COMPONENT, Component[0], '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
for Item in Component[1]:
- List = GetSplitValueList(Item, MaxSplit = 2)
+ List = GetSplitValueList(Item, MaxSplit=2)
LibName, LibIns = '', ''
if len(List) == 2:
LibName = List[0]
diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/Source/Python/Common/InfClassObject.py index 0f2b5ca47d..7ea0c39297 100644 --- a/BaseTools/Source/Python/Common/InfClassObject.py +++ b/BaseTools/Source/Python/Common/InfClassObject.py @@ -163,7 +163,7 @@ class InfObject(object): # @var KeyList: To store value for KeyList, a list for all Keys used in Inf
#
class Inf(InfObject):
- def __init__(self, Filename = None, IsToDatabase = False, IsToModule = False, WorkspaceDir = None, Database = None, SupArchList = DataType.ARCH_LIST):
+ def __init__(self, Filename=None, IsToDatabase=False, IsToModule=False, WorkspaceDir=None, Database=None, SupArchList=DataType.ARCH_LIST):
self.Identification = Identification()
self.Module = ModuleClass()
self.UserExtensions = ''
@@ -353,10 +353,10 @@ class Inf(InfObject): # Remove comment block
#
if Line.find(TAB_COMMENT_EDK_START) > -1:
- ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]
+ ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0]
IsFindBlockComment = True
if Line.find(TAB_COMMENT_EDK_END) > -1:
- Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]
+ Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1]
ReservedLine = ''
IsFindBlockComment = False
if IsFindBlockComment:
@@ -397,7 +397,7 @@ class Inf(InfObject): CurrentSection = ItemList[0]
else:
if CurrentSection != ItemList[0]:
- EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
if CurrentSection.upper() not in self.KeyList:
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
CurrentSection = TAB_UNKNOWN
@@ -408,7 +408,7 @@ class Inf(InfObject): RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
else:
if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
- EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
ArchList.append(ItemList[1].upper())
ThirdList.append(ItemList[2])
@@ -419,7 +419,7 @@ class Inf(InfObject): #
if CurrentSection == TAB_UNKNOWN:
ErrorMsg = "%s is not in any defined section" % Line
- EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
#
# Add a section item
@@ -497,13 +497,13 @@ class Inf(InfObject): print Item.Name, Item.Value, Item.SupArchList
print '\nPcds =', M.PcdCodes
for Item in M.PcdCodes:
- print '\tCName=',Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, Item.SupArchList
+ print '\tCName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, Item.SupArchList
print '\nSources =', M.Sources
for Source in M.Sources:
print Source.SourceFile, 'Fam=', Source.ToolChainFamily, 'Pcd=', Source.FeatureFlag, 'Tag=', Source.TagName, 'ToolCode=', Source.ToolCode, Source.SupArchList
print '\nUserExtensions =', M.UserExtensions
for UserExtension in M.UserExtensions:
- print UserExtension.UserID, UserExtension.Identifier,UserExtension.Content
+ print UserExtension.UserID, UserExtension.Identifier, UserExtension.Content
print '\nGuids =', M.Guids
for Item in M.Guids:
print Item.CName, Item.SupArchList, Item.FeatureFlag
@@ -629,7 +629,7 @@ class Inf(InfObject): if ModuleHeader.ComponentType in gComponentType2ModuleType:
ModuleHeader.ModuleType = gComponentType2ModuleType[ModuleHeader.ComponentType]
elif ModuleHeader.ComponentType != '':
- EdkLogger.error("Parser", PARSER_ERROR, "Unsupported Edk component type [%s]" % ModuleHeader.ComponentType, ExtraData=File, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Unsupported Edk component type [%s]" % ModuleHeader.ComponentType, ExtraData=File, RaiseError=EdkLogger.IsRaiseError)
self.Module.Header[Arch] = ModuleHeader
diff --git a/BaseTools/Source/Python/Common/InfClassObjectLight.py b/BaseTools/Source/Python/Common/InfClassObjectLight.py index 067bf71008..44f922340b 100644 --- a/BaseTools/Source/Python/Common/InfClassObjectLight.py +++ b/BaseTools/Source/Python/Common/InfClassObjectLight.py @@ -73,7 +73,7 @@ class InfHeader(ModuleHeaderClass): TAB_INF_DEFINES_MODULE_TYPE : "ModuleType",
TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION : "UefiSpecificationVersion",
TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : "UefiSpecificationVersion",
- TAB_INF_DEFINES_EDK_RELEASE_VERSION : "EdkReleaseVersion",
+ TAB_INF_DEFINES_EDK_RELEASE_VERSION : "EdkReleaseVersion",
# Optional Fields
TAB_INF_DEFINES_INF_VERSION : "InfVersion",
@@ -139,34 +139,34 @@ class InfObject(object): # @var KeyList: To store value for KeyList, a list for all Keys used in Inf
#
class Inf(InfObject):
- def __init__(self, Filename = None, IsToModule = False, WorkspaceDir = None, PackageDir = None, SupArchList = DataType.ARCH_LIST):
+ def __init__(self, Filename=None, IsToModule=False, WorkspaceDir=None, PackageDir=None, SupArchList=DataType.ARCH_LIST):
self.Identification = IdentificationClass()
self.Module = ModuleClass()
self.WorkspaceDir = WorkspaceDir
self.PackageDir = PackageDir
self.SupArchList = SupArchList
-
+
self.KeyList = [
- TAB_SOURCES, TAB_BUILD_OPTIONS, TAB_BINARIES, TAB_INCLUDES, TAB_GUIDS,
- TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, TAB_PACKAGES, TAB_INF_FIXED_PCD,
- TAB_INF_PATCH_PCD, TAB_INF_FEATURE_PCD, TAB_INF_PCD, TAB_INF_PCD_EX,
+ TAB_SOURCES, TAB_BUILD_OPTIONS, TAB_BINARIES, TAB_INCLUDES, TAB_GUIDS,
+ TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, TAB_PACKAGES, TAB_INF_FIXED_PCD,
+ TAB_INF_PATCH_PCD, TAB_INF_FEATURE_PCD, TAB_INF_PCD, TAB_INF_PCD_EX,
TAB_DEPEX, TAB_INF_DEFINES
]
# Upper all KEYs to ignore case sensitive when parsing
self.KeyList = map(lambda c: c.upper(), self.KeyList)
-
+
# Init RecordSet
- self.RecordSet = {}
+ self.RecordSet = {}
for Key in self.KeyList:
self.RecordSet[Section[Key]] = []
-
+
# Init Comment
self.SectionHeaderCommentDict = {}
-
+
# Load Inf file if filename is not None
if Filename != None:
self.LoadInfFile(Filename)
-
+
# Transfer to Module Object if IsToModule is True
if IsToModule:
self.InfToModule()
@@ -209,16 +209,16 @@ class Inf(InfObject): InfList['Defines'] = TmpList
if ModuleHeader.Description != '':
SectionHeaderCommentDict['Defines'] = ModuleHeader.Description
-
+
if Module.UserExtensions != None:
InfList['BuildOptions'] = Module.UserExtensions.BuildOptions
-
+
for Item in Module.Includes:
Key = 'Includes.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
Value.append(Item.FilePath)
GenMetaDatSectionItem(Key, Value, InfList)
-
+
for Item in Module.LibraryClasses:
Key = 'LibraryClasses.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
@@ -227,15 +227,15 @@ class Inf(InfObject): NewValue = NewValue + '|' + Item.RecommendedInstance
if Item.FeatureFlag:
NewValue = NewValue + '|' + Item.FeatureFlag
- Value.append(NewValue)
+ Value.append(NewValue)
GenMetaDatSectionItem(Key, Value, InfList)
-
+
for Item in Module.PackageDependencies:
Key = 'Packages.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
Value.append(Item.FilePath)
GenMetaDatSectionItem(Key, Value, InfList)
-
+
for Item in Module.PcdCodes:
Key = 'Pcds' + Item.ItemType + '.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
@@ -244,7 +244,7 @@ class Inf(InfObject): NewValue = NewValue + '|' + Item.DefaultValue
Value.append(NewValue)
GenMetaDatSectionItem(Key, Value, InfList)
-
+
for Item in Module.Sources:
Key = 'Sources.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
@@ -261,40 +261,40 @@ class Inf(InfObject): if Item.HelpText != '':
SectionHeaderCommentDict[Key] = Item.HelpText
GenMetaDatSectionItem(Key, Value, InfList)
-
+
for Item in Module.Guids:
Key = 'Guids.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
Value.append(Item.CName)
GenMetaDatSectionItem(Key, Value, InfList)
-
+
for Item in Module.Protocols:
Key = 'Protocols.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
Value.append(Item.CName)
GenMetaDatSectionItem(Key, Value, InfList)
-
+
for Item in Module.Ppis:
Key = 'Ppis.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
Value.append(Item.CName)
GenMetaDatSectionItem(Key, Value, InfList)
-
+
if Module.PeiDepex:
Key = 'Depex'
Value = Module.PeiDepex.Depex
GenMetaDatSectionItem(Key, Value, InfList)
-
+
if Module.DxeDepex:
Key = 'Depex'
Value = Module.DxeDepex.Depex
GenMetaDatSectionItem(Key, Value, InfList)
-
+
if Module.SmmDepex:
Key = 'Depex'
Value = Module.SmmDepex.Depex
GenMetaDatSectionItem(Key, Value, InfList)
-
+
for Item in Module.Binaries:
Key = 'Binaries.' + GetStringOfList(Item.SupArchList)
Value = GetHelpTextList(Item.HelpTextList)
@@ -318,10 +318,10 @@ class Inf(InfObject): else:
Inf = Inf + ' ' + Value + '\n'
Inf = Inf + '\n'
-
+
return Inf
-
-
+
+
## Transfer to Module Object
#
# Transfer all contents of an Inf file to a standard Module Object
@@ -329,28 +329,28 @@ class Inf(InfObject): def InfToModule(self):
# Init global information for the file
ContainerFile = self.Identification.FullPath
-
+
# Generate Module Header
self.GenModuleHeader(ContainerFile)
-
+
# Generate BuildOptions
self.GenBuildOptions(ContainerFile)
-
+
# Generate Includes
self.GenIncludes(ContainerFile)
-
+
# Generate LibraryClasses
self.GenLibraryClasses(ContainerFile)
-
+
# Generate Packages
self.GenPackages(ContainerFile)
-
+
# Generate Pcds
self.GenPcds(ContainerFile)
-
+
# Generate Sources
self.GenSources(ContainerFile)
-
+
# Generate Guids
self.GenGuidProtocolPpis(DataType.TAB_GUIDS, ContainerFile)
@@ -359,13 +359,13 @@ class Inf(InfObject): # Generate Ppis
self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile)
-
+
# Generate Depexes
self.GenDepexes(ContainerFile)
-
+
# Generate Binaries
self.GenBinaries(ContainerFile)
-
+
# Init MiscFiles
self.GenMiscFiles(ContainerFile)
@@ -386,24 +386,24 @@ class Inf(InfObject): #
# @param Filename: Input value for filename of Inf file
#
- def LoadInfFile(self, Filename):
+ def LoadInfFile(self, Filename):
# Insert a record for file
Filename = NormPath(Filename)
-
+
self.Identification.FullPath = Filename
(self.Identification.RelaPath, self.Identification.FileName) = os.path.split(Filename)
if self.Identification.FullPath.find(self.WorkspaceDir) > -1:
- self.Identification.ModulePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:])
+ self.Identification.ModulePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:])
if self.PackageDir:
self.Identification.PackagePath = self.PackageDir
if self.Identification.ModulePath.find(self.PackageDir) == 0:
self.Identification.ModulePath = self.Identification.ModulePath[len(self.PackageDir) + 1:]
-
+
# Init common datas
IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \
[], [], TAB_UNKNOWN, [], [], []
LineNo = 0
-
+
# Parse file content
IsFindBlockComment = False
ReservedLine = ''
@@ -412,7 +412,7 @@ class Inf(InfObject): LineNo = LineNo + 1
# Remove comment block
if Line.find(TAB_COMMENT_EDK_START) > -1:
- ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]
+ ReservedLine = GetSplitList(Line, TAB_COMMENT_EDK_START, 1)[0]
if ReservedLine.strip().startswith(TAB_COMMENT_SPLIT):
Comment = Comment + Line.strip() + '\n'
ReservedLine = ''
@@ -423,20 +423,20 @@ class Inf(InfObject): continue
if Line.find(TAB_COMMENT_EDK_END) > -1:
Comment = Comment + Line[:Line.find(TAB_COMMENT_EDK_END) + len(TAB_COMMENT_EDK_END)] + '\n'
- Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]
+ Line = ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK_END, 1)[1]
ReservedLine = ''
IsFindBlockComment = False
if IsFindBlockComment:
Comment = Comment + Line.strip() + '\n'
continue
-
+
# Remove comments at tail and remove spaces again
if Line.strip().startswith(TAB_COMMENT_SPLIT) or Line.strip().startswith('--/'):
Comment = Comment + Line.strip() + '\n'
Line = CleanString(Line)
if Line == '':
continue
-
+
## Find a new section tab
# First insert previous section items
# And then parse the content of the new section
@@ -446,12 +446,12 @@ class Inf(InfObject): Model = Section[CurrentSection.upper()]
# Insert items data of previous section
InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, self.RecordSet)
-
+
# Parse the new section
SectionItemList = []
ArchList = []
ThirdList = []
-
+
CurrentSection = ''
LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
for Item in LineList:
@@ -460,7 +460,7 @@ class Inf(InfObject): CurrentSection = ItemList[0]
else:
if CurrentSection != ItemList[0]:
- EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
if CurrentSection.upper() not in self.KeyList:
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
ItemList.append('')
@@ -469,7 +469,7 @@ class Inf(InfObject): RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
else:
if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
- EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
ArchList.append(ItemList[1].upper())
ThirdList.append(ItemList[2])
@@ -479,18 +479,18 @@ class Inf(InfObject): self.SectionHeaderCommentDict[Section[CurrentSection.upper()]] = Comment
Comment = ''
continue
-
+
# Not in any defined section
if CurrentSection == TAB_UNKNOWN:
ErrorMsg = "%s is not in any defined section" % Line
- EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
# Add a section item
SectionItemList.append([Line, LineNo, Comment])
Comment = ''
# End of parse
#End of For
-
+
# Insert items data of last section
Model = Section[CurrentSection.upper()]
InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, self.RecordSet)
@@ -510,7 +510,7 @@ class Inf(InfObject): print 'PackagePath =', M.ModuleHeader.PackagePath
print 'ModulePath =', M.ModuleHeader.ModulePath
print 'CombinePath =', M.ModuleHeader.CombinePath
-
+
print 'BaseName =', M.ModuleHeader.Name
print 'Guid =', M.ModuleHeader.Guid
print 'Version =', M.ModuleHeader.Version
@@ -526,7 +526,7 @@ class Inf(InfObject): print Item.FilePath, Item.SupArchList, Item.FeatureFlag
print '\nPcds ='
for Item in M.PcdCodes:
- print '\tCName=',Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, Item.SupArchList
+ print '\tCName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, Item.SupArchList
print '\nSources ='
for Source in M.Sources:
print Source.SourceFile, 'Fam=', Source.ToolChainFamily, 'Pcd=', Source.FeatureFlag, 'Tag=', Source.TagName, 'ToolCode=', Source.ToolCode, Source.SupArchList
@@ -562,7 +562,7 @@ class Inf(InfObject): EdkLogger.debug(2, "Generate ModuleHeader ...")
# Update all defines item in database
RecordSet = self.RecordSet[MODEL_META_DATA_HEADER]
-
+
ModuleHeader = ModuleHeaderClass()
ModuleExtern = ModuleExternClass()
OtherDefines = []
@@ -614,7 +614,7 @@ class Inf(InfObject): UE = UserExtensionsClass()
UE.Defines = OtherDefines
self.Module.UserExtensions = UE
-
+
## GenBuildOptions
#
# Gen BuildOptions of Inf
@@ -633,7 +633,7 @@ class Inf(InfObject): for Record in RecordSet:
UE.BuildOptions.append(Record[0])
self.Module.UserExtensions = UE
-
+
## GenIncludes
#
# Gen Includes of Inf
@@ -653,7 +653,7 @@ class Inf(InfObject): Include.HelpTextList.append(GenerateHelpText(Record[5], ''))
self.Module.Includes.append(Include)
#self.Module.FileList.extend(GetFiles(os.path.normpath(os.path.join(self.Identification.FileRelativePath, Include.FilePath)), ['CVS', '.svn']))
-
+
## GenLibraryClasses
#
# Get LibraryClass of Inf
@@ -667,7 +667,7 @@ class Inf(InfObject): # Get all LibraryClasses
RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS]
for Record in RecordSet:
- (LibClassName, LibClassIns, Pcd, SupModelList) = GetLibraryClassOfInf([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])
+ (LibClassName, LibClassIns, Pcd, SupModelList) = GetLibraryClassOfInf([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])
LibraryClass = CommonClass.LibraryClassClass()
LibraryClass.LibraryClass = LibClassName
LibraryClass.RecommendedInstance = LibClassIns
@@ -698,7 +698,7 @@ class Inf(InfObject): if GenerateHelpText(Record[5], ''):
Package.HelpTextList.append(GenerateHelpText(Record[5], ''))
self.Module.PackageDependencies.append(Package)
-
+
def AddPcd(self, CName, TokenSpaceGuidCName, DefaultValue, ItemType, Arch, HelpTextList):
Pcd = PcdClass()
Pcd.CName = CName
@@ -709,7 +709,7 @@ class Inf(InfObject): if GenerateHelpText(HelpTextList, ''):
Pcd.HelpTextList.append(GenerateHelpText(HelpTextList, ''))
self.Module.PcdCodes.append(Pcd)
-
+
## GenPcds
#
# Gen Pcds of Inf
@@ -721,14 +721,14 @@ class Inf(InfObject): EdkLogger.debug(2, "Generate %s ..." % TAB_PCDS)
Pcds = {}
PcdToken = {}
-
+
# Get all Pcds
RecordSet1 = self.RecordSet[MODEL_PCD_FIXED_AT_BUILD]
RecordSet2 = self.RecordSet[MODEL_PCD_PATCHABLE_IN_MODULE]
RecordSet3 = self.RecordSet[MODEL_PCD_FEATURE_FLAG]
RecordSet4 = self.RecordSet[MODEL_PCD_DYNAMIC_EX]
RecordSet5 = self.RecordSet[MODEL_PCD_DYNAMIC]
-
+
# Go through each arch
for Record in RecordSet1:
(TokenSpaceGuidCName, TokenName, Value, Type) = GetPcdOfInf(Record[0], TAB_PCDS_FIXED_AT_BUILD, ContainerFile, Record[2])
@@ -745,7 +745,7 @@ class Inf(InfObject): for Record in RecordSet5:
(TokenSpaceGuidCName, TokenName, Value, Type) = GetPcdOfInf(Record[0], '', ContainerFile, Record[2])
self.AddPcd(TokenName, TokenSpaceGuidCName, Value, Type, Record[1], Record[5])
-
+
## GenSources
#
# Gen Sources of Inf
@@ -756,7 +756,7 @@ class Inf(InfObject): def GenSources(self, ContainerFile):
EdkLogger.debug(2, "Generate %s ..." % TAB_SOURCES)
Sources = {}
-
+
# Get all Sources
RecordSet = self.RecordSet[MODEL_EFI_SOURCE_FILE]
for Record in RecordSet:
@@ -820,7 +820,7 @@ class Inf(InfObject): def GenBinaries(self, ContainerFile):
EdkLogger.debug(2, "Generate %s ..." % TAB_BINARIES)
Binaries = {}
-
+
# Get all Guids
RecordSet = self.RecordSet[MODEL_EFI_BINARY_FILE]
for Record in RecordSet:
@@ -830,7 +830,7 @@ class Inf(InfObject): Binary.HelpTextList.append(GenerateHelpText(Record[5], ''))
self.Module.Binaries.append(Binary)
#self.Module.FileList.append(os.path.normpath(os.path.join(self.Identification.RelaPath, Filename)))
-
+
## GenGuids
#
# Gen Guids of Inf
@@ -859,7 +859,7 @@ class Inf(InfObject): if GenerateHelpText(Record[5], ''):
ListClass.HelpTextList.append(GenerateHelpText(Record[5], ''))
ListMember.append(ListClass)
-
+
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
@@ -868,10 +868,10 @@ class Inf(InfObject): if __name__ == '__main__':
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.QUIET)
-
+
W = os.getenv('WORKSPACE')
F = os.path.join(W, 'MdeModulePkg/Application/HelloWorld/HelloWorld.inf')
-
+
P = Inf(os.path.normpath(F), True, W, 'MdeModulePkg')
P.ShowModule()
print P.ModuleToInf(P.Module)
diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py index a35f728dc0..0f2a61b1b9 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -24,7 +24,7 @@ import GlobalData from BuildToolError import *
from CommonDataClass.Exceptions import *
-gHexVerPatt = re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$',re.IGNORECASE)
+gHexVerPatt = re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$', re.IGNORECASE)
gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$')
## GetSplitValueList
@@ -39,7 +39,7 @@ gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$') #
# @retval list() A list for splitted string
#
-def GetSplitValueList(String, SplitTag = DataType.TAB_VALUE_SPLIT, MaxSplit = -1):
+def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
ValueList = []
Last = 0
Escaped = False
@@ -51,7 +51,7 @@ def GetSplitValueList(String, SplitTag = DataType.TAB_VALUE_SPLIT, MaxSplit = -1 # Found a splitter not in a string, split it
if not InString and Char == SplitTag:
ValueList.append(String[Last:Index].strip())
- Last = Index+1
+ Last = Index + 1
if MaxSplit > 0 and len(ValueList) >= MaxSplit:
break
@@ -84,7 +84,7 @@ def GetSplitValueList(String, SplitTag = DataType.TAB_VALUE_SPLIT, MaxSplit = -1 #
# @retval list() A list for splitted string
#
-def GetSplitList(String, SplitStr = DataType.TAB_VALUE_SPLIT, MaxSplit = -1):
+def GetSplitList(String, SplitStr=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
return map(lambda l: l.strip(), String.split(SplitStr, MaxSplit))
## MergeArches
@@ -235,7 +235,7 @@ def SplitModuleType(Key): #
# @retval NewList A new string list whose macros are replaced
#
-def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement = False):
+def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False):
NewList = []
for String in StringList:
if type(String) == type(''):
@@ -289,7 +289,7 @@ def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement=False, RaiseError= #
# @retval Path Formatted path
#
-def NormPath(Path, Defines = {}):
+def NormPath(Path, Defines={}):
IsRelativePath = False
if Path:
if Path[0] == '.':
@@ -319,7 +319,7 @@ def NormPath(Path, Defines = {}): #
# @retval Path Formatted path
#
-def CleanString(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT, AllowCppStyleComment=False):
+def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyleComment=False):
#
# remove whitespace
#
@@ -342,19 +342,19 @@ def CleanString(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT, AllowCppSty elif Line[Index] == CommentCharacter and not InString :
Line = Line[0: Index]
break
-
+
if CommentInString:
Line = Line.replace('"', '')
ChIndex = Line.find('#')
while ChIndex >= 0:
if GlobalData.gIsWindows:
- if ChIndex == 0 or Line[ChIndex-1] != '^':
+ if ChIndex == 0 or Line[ChIndex - 1] != '^':
Line = Line[0:ChIndex] + '^' + Line[ChIndex:]
ChIndex = Line.find('#', ChIndex + 2)
else:
ChIndex = Line.find('#', ChIndex + 1)
else:
- if ChIndex == 0 or Line[ChIndex-1] != '\\':
+ if ChIndex == 0 or Line[ChIndex - 1] != '\\':
Line = Line[0:ChIndex] + '\\' + Line[ChIndex:]
ChIndex = Line.find('#', ChIndex + 2)
else:
@@ -376,7 +376,7 @@ def CleanString(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT, AllowCppSty #
# @retval Path Formatted path
#
-def CleanString2(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT, AllowCppStyleComment=False):
+def CleanString2(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyleComment=False):
#
# remove whitespace
#
@@ -468,7 +468,7 @@ def GetHexVerValue(VerString): if len(Minor) == 1:
Minor += '0'
DeciValue = (int(Major) << 16) + int(Minor);
- return "0x%08x"%DeciValue
+ return "0x%08x" % DeciValue
elif gHexVerPatt.match(VerString):
return VerString
else:
@@ -578,7 +578,7 @@ def PreCheck(FileName, FileContent, SupSectionTag): #
if Line.find('$') > -1:
if Line.find('$(') < 0 or Line.find(')') < 0:
- EdkLogger.error("Parser", FORMAT_INVALID, Line=LineNo, File=FileName, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", FORMAT_INVALID, Line=LineNo, File=FileName, RaiseError=EdkLogger.IsRaiseError)
#
# Check []
@@ -588,7 +588,7 @@ def PreCheck(FileName, FileContent, SupSectionTag): # Only get one '[' or one ']'
#
if not (Line.find('[') > -1 and Line.find(']') > -1):
- EdkLogger.error("Parser", FORMAT_INVALID, Line=LineNo, File=FileName, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", FORMAT_INVALID, Line=LineNo, File=FileName, RaiseError=EdkLogger.IsRaiseError)
#
# Regenerate FileContent
@@ -596,7 +596,7 @@ def PreCheck(FileName, FileContent, SupSectionTag): NewFileContent = NewFileContent + Line + '\r\n'
if IsFailed:
- EdkLogger.error("Parser", FORMAT_INVALID, Line=LineNo, File=FileName, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", FORMAT_INVALID, Line=LineNo, File=FileName, RaiseError=EdkLogger.IsRaiseError)
return NewFileContent
@@ -614,7 +614,7 @@ def PreCheck(FileName, FileContent, SupSectionTag): #
# @retval True The file type is correct
#
-def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line, LineNo = -1):
+def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line, LineNo= -1):
if CheckFilename != '' and CheckFilename != None:
(Root, Ext) = os.path.splitext(CheckFilename)
if Ext.upper() != ExtName.upper():
@@ -623,7 +623,7 @@ def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line, LineNo = GetLineNo(ContainerFile, Line)
ErrorMsg = "Invalid %s. '%s' is found, but '%s' file is needed" % (SectionName, CheckFilename, ExtName)
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, Line=LineNo,
- File=ContainerFilename, RaiseError = EdkLogger.IsRaiseError)
+ File=ContainerFilename, RaiseError=EdkLogger.IsRaiseError)
return True
@@ -641,7 +641,7 @@ def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line, #
# @retval The file full path if the file exists
#
-def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, SectionName, Line, LineNo = -1):
+def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, SectionName, Line, LineNo= -1):
CheckFile = ''
if CheckFilename != '' and CheckFilename != None:
CheckFile = WorkspaceFile(WorkspaceDir, CheckFilename)
@@ -651,7 +651,7 @@ def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, SectionName, LineNo = GetLineNo(ContainerFile, Line)
ErrorMsg = "Can't find file '%s' defined in section '%s'" % (CheckFile, SectionName)
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg,
- File=ContainerFilename, Line = LineNo, RaiseError = EdkLogger.IsRaiseError)
+ File=ContainerFilename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
return CheckFile
@@ -665,7 +665,7 @@ def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, SectionName, # @retval int Index of the line
# @retval -1 The line is not found
#
-def GetLineNo(FileContent, Line, IsIgnoreComment = True):
+def GetLineNo(FileContent, Line, IsIgnoreComment=True):
LineList = FileContent.splitlines()
for Index in range(len(LineList)):
if LineList[Index].find(Line) > -1:
@@ -688,13 +688,13 @@ def GetLineNo(FileContent, Line, IsIgnoreComment = True): # @param File: File which has the string
# @param Format: Correct format
#
-def RaiseParserError(Line, Section, File, Format = '', LineNo = -1):
+def RaiseParserError(Line, Section, File, Format='', LineNo= -1):
if LineNo == -1:
LineNo = GetLineNo(open(os.path.normpath(File), 'r').read(), Line)
ErrorMsg = "Invalid statement '%s' is found in section '%s'" % (Line, Section)
if Format != '':
Format = "Correct format is " + Format
- EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=File, Line=LineNo, ExtraData=Format, RaiseError = EdkLogger.IsRaiseError)
+ EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=File, Line=LineNo, ExtraData=Format, RaiseError=EdkLogger.IsRaiseError)
## WorkspaceFile
#
@@ -757,10 +757,10 @@ def RemoveBlockComment(Lines): # Remove comment block
#
if Line.find(DataType.TAB_COMMENT_EDK_START) > -1:
- ReservedLine = GetSplitValueList(Line, DataType.TAB_COMMENT_EDK_START, 1)[0]
+ ReservedLine = GetSplitList(Line, DataType.TAB_COMMENT_EDK_START, 1)[0]
IsFindBlockComment = True
if Line.find(DataType.TAB_COMMENT_EDK_END) > -1:
- Line = ReservedLine + GetSplitValueList(Line, DataType.TAB_COMMENT_EDK_END, 1)[1]
+ Line = ReservedLine + GetSplitList(Line, DataType.TAB_COMMENT_EDK_END, 1)[1]
ReservedLine = ''
IsFindBlockComment = False
if IsFindBlockComment:
@@ -773,7 +773,7 @@ def RemoveBlockComment(Lines): #
# Get String of a List
#
-def GetStringOfList(List, Split = ' '):
+def GetStringOfList(List, Split=' '):
if type(List) != type([]):
return List
Str = ''
@@ -797,7 +797,7 @@ def GetHelpTextList(HelpTextClassList): def StringToArray(String):
if isinstance(String, unicode):
- if len(unicode) ==0:
+ if len(unicode) == 0:
return "{0x00, 0x00}"
return "{%s, 0x00, 0x00}" % ", ".join(["0x%02x, 0x00" % ord(C) for C in String])
elif String.startswith('L"'):
@@ -822,7 +822,7 @@ def StringArrayLength(String): return (len(String) - 2 + 1)
else:
return len(String.split()) + 1
-
+
def RemoveDupOption(OptionString, Which="/I", Against=None):
OptionList = OptionString.split()
ValueList = []
|