X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FEcc%2FMetaFileWorkspace%2FMetaFileParser.py;h=237cf5acfea13ad0210cf3edda189e1b8d2fbe9f;hp=734912f0f1e7857937f745515f58df1667932541;hb=0b560b980ce00588e540a480532dd48328a9f003;hpb=ce2f5940060c20261a7d22f5ce5c767bb8f298b0 diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 734912f0f1..237cf5acfe 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -228,7 +228,7 @@ class MetaFileParser(object): self.Start() # No specific ARCH or Platform given, use raw data - if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] == None): + if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] is None): return self._RawTable.Query(*DataInfo) # Do post-process if necessary @@ -564,7 +564,7 @@ class InfParser(MetaFileParser): self._ValueList = ['','',''] # parse current line, result will be put in self._ValueList self._SectionParser[self._SectionType](self) - if self._ValueList == None or self._ItemType == MODEL_META_DATA_DEFINE: + if self._ValueList is None or self._ItemType == MODEL_META_DATA_DEFINE: self._ItemType = -1 continue # @@ -783,6 +783,10 @@ class DscParser(MetaFileParser): "FIX_LOAD_TOP_MEMORY_ADDRESS" ] + SubSectionDefineKeywords = [ + "FILE_GUID" + ] + SymbolPattern = ValueExpression.SymbolPattern ## Constructor of DscParser @@ -873,7 +877,7 @@ class DscParser(MetaFileParser): self._ValueList = ['', '', ''] self._SectionParser[SectionType](self) - if self._ValueList == None: + if self._ValueList is None: continue # # Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1, @@ -993,7 +997,8 @@ class DscParser(MetaFileParser): if not self._ValueList[2]: EdkLogger.error('Parser', FORMAT_INVALID, "No value specified", ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) - if not self._ValueList[1] in self.DefineKeywords: + if (not self._ValueList[1] in self.DefineKeywords and + (self._InSubsection and self._ValueList[1] not in self.SubSectionDefineKeywords)): EdkLogger.error('Parser', FORMAT_INVALID, "Unknown keyword found: %s. " "If this is a macro you must " @@ -1192,7 +1197,7 @@ class DscParser(MetaFileParser): File=self._FileWithError, ExtraData=' '.join(self._ValueList), Line=self._LineIndex+1) - if self._ValueList == None: + if self._ValueList is None: continue NewOwner = self._IdMapping.get(Owner, -1) @@ -1568,7 +1573,7 @@ class DecParser(MetaFileParser): # section content self._ValueList = ['','',''] self._SectionParser[self._SectionType[0]](self) - if self._ValueList == None or self._ItemType == MODEL_META_DATA_DEFINE: + if self._ValueList is None or self._ItemType == MODEL_META_DATA_DEFINE: self._ItemType = -1 self._Comments = [] continue @@ -1709,7 +1714,8 @@ class DecParser(MetaFileParser): continue else: if GuidValue.startswith('{'): - HexList.append('0x' + str(GuidValue[3:])) + GuidValue = GuidValue.lstrip(' {') + HexList.append('0x' + str(GuidValue[2:])) Index += 1 self._ValueList[1] = "{ %s, %s, %s, { %s, %s, %s, %s, %s, %s, %s, %s }}" % (HexList[0], HexList[1], HexList[2],HexList[3],HexList[4],HexList[5],HexList[6],HexList[7],HexList[8],HexList[9],HexList[10]) else: @@ -1894,25 +1900,14 @@ class DecParser(MetaFileParser): } -## FdfObject -# -# This class defined basic Fdf object which is used by inheriting -# -# @param object: Inherited from object class -# -class FdfObject(object): - def __init__(self): - object.__init__() - ## Fdf # # This class defined the structure used in Fdf object # -# @param FdfObject: Inherited from FdfObject class # @param Filename: Input value for Ffilename of Fdf file, default is None # @param WorkspaceDir: Input value for current workspace directory, default is None # -class Fdf(FdfObject): +class Fdf(object): def __init__(self, Filename = None, IsToDatabase = False, WorkspaceDir = None, Database = None): self.WorkspaceDir = WorkspaceDir self.IsToDatabase = IsToDatabase @@ -1926,7 +1921,7 @@ class Fdf(FdfObject): # # Load Fdf file if filename is not None # - if Filename != None: + if Filename is not None: try: self.LoadFdfFile(Filename) except Exception: @@ -1999,9 +1994,11 @@ class UniParser(object): def __read(self): try: - self.FileIn = CodecOpenLongFilePath(self.FilePath, Mode = 'rb', Encoding = 'utf_16').read() + self.FileIn = CodecOpenLongFilePath(self.FilePath, Mode='rb', Encoding='utf_8').read() + except UnicodeError: + self.FileIn = CodecOpenLongFilePath(self.FilePath, Mode='rb', Encoding='utf_16').read() except UnicodeError: - self.FileIn = CodecOpenLongFilePath(self.FilePath, Mode = 'rb', Encoding = 'utf_16_le').read() + self.FileIn = CodecOpenLongFilePath(self.FilePath, Mode='rb', Encoding='utf_16_le').read() except IOError: self.FileIn = ""