def _UserExtentionSectionParser(self): self._RawData.CurrentScope = [] ArchList = set() Section = self._RawData.CurrentLine[1:-1] Par = ParserHelper(Section, self._RawData.Filename) while not Par.End(): # # User extention # Token = Par.GetToken() if Token.upper() != DT.TAB_USER_EXTENSIONS.upper(): self._LoggerError(ST.ERR_DECPARSE_SECTION_UE) UserExtension = Token.upper() Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex) # # UserID # Token = Par.GetToken() if not IsValidUserId(Token): self._LoggerError(ST.ERR_DECPARSE_SECTION_UE_USERID) UserId = Token Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex) # # IdString # Token = Par.GetToken() if not IsValidIdString(Token): self._LoggerError(ST.ERR_DECPARSE_SECTION_UE_IDSTRING) IdString = Token Arch = 'COMMON' if Par.Expect(DT.TAB_SPLIT): Token = Par.GetToken() Arch = Token.upper() if not IsValidArch(Arch): self._LoggerError(ST.ERR_DECPARSE_ARCH) ArchList.add(Arch) if [UserExtension, UserId, IdString, Arch] not in \ self._RawData.CurrentScope: self._RawData.CurrentScope.append( [UserExtension, UserId, IdString, Arch]) if not Par.Expect(DT.TAB_COMMA_SPLIT): break elif Par.End(): self._LoggerError(ST.ERR_DECPARSE_SECTION_COMMA) Par.AssertEnd(ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex) if 'COMMON' in ArchList and len(ArchList) > 1: self._LoggerError(ST.ERR_DECPARSE_SECTION_COMMON)
def InfUserExtensionParser(self, SectionString, InfSectionObject, FileName): UserExtensionContent = '' # # Parse section content # for Line in SectionString: LineContent = Line[0] # Comment the code to support user extension without any statement just the section header in [] # if LineContent.strip() == '': # continue UserExtensionContent += LineContent + DT.END_OF_LINE continue # # Current section UserId, IdString # IdContentList = [] LastItem = '' SectionLineNo = None for Item in self.LastSectionHeaderContent: UserId = Item[1] IdString = Item[2] Arch = Item[3] SectionLineNo = Item[4] if not IsValidArch(Arch): Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Arch), File=GlobalData.gINF_MODULE_NAME, Line=SectionLineNo, ExtraData=None) if (UserId, IdString, Arch) not in IdContentList: # # To check the UserId and IdString valid or not. # if not IsValidUserId(UserId): Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_INF_PARSER_UE_SECTION_USER_ID_ERROR % (Item[1]), File=GlobalData.gINF_MODULE_NAME, Line=SectionLineNo, ExtraData=None) if not IsValidIdString(IdString): Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_INF_PARSER_UE_SECTION_ID_STRING_ERROR % (IdString), File=GlobalData.gINF_MODULE_NAME, Line=SectionLineNo, ExtraData=None) IdContentList.append((UserId, IdString, Arch)) else: # # Each UserExtensions section header must have a unique set # of UserId, IdString and Arch values. # This means that the same UserId can be used in more than one # section header, provided the IdString or Arch values are # different. The same IdString values can be used in more than # one section header if the UserId or Arch values are # different. The same UserId and the same IdString can be used # in a section header if the Arch values are different in each # of the section headers. # Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR % (IdString), File=GlobalData.gINF_MODULE_NAME, Line=SectionLineNo, ExtraData=None) LastItem = Item if not InfSectionObject.SetUserExtension(UserExtensionContent, IdContent=IdContentList, LineNo=SectionLineNo): Logger.Error\ ('InfParser', FORMAT_INVALID, \ ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[UserExtension]"), \ File=FileName, Line=LastItem[4])