def LoadIdfFile(self, File=None): if File == None: EdkLogger.error("Image Definition File Parser", PARSER_ERROR, 'No Image definition file is given.') self.File = File try: IdfFile = open(LongFilePath(File.Path), mode='r') FileIn = IdfFile.read() IdfFile.close() except: EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=File) ImageFileList = [] for Line in FileIn.splitlines(): Line = Line.strip() Line = self.StripComments(Line) if len(Line) == 0: continue if Line.find('#image ') >= 0: LineDetails = Line.split() LineNo = GetLineNo(FileIn, Line, False) Len = len(LineDetails) if Len != 3 and Len != 4: EdkLogger.error( "Image Definition File Parser", PARSER_ERROR, 'The format is not match #image IMAGE_ID [TRANSPARENT] ImageFileName in Line %s of File %s.' % (LineNo, File.Path)) if Len == 4 and LineDetails[2] != 'TRANSPARENT': EdkLogger.error( "Image Definition File Parser", PARSER_ERROR, 'Please use the keyword "TRANSPARENT" to describe the transparency setting in Line %s of File %s.' % (LineNo, File.Path)) MatchString = re.match('^[a-zA-Z][a-zA-Z0-9_]*$', LineDetails[1], re.UNICODE) if MatchString == None or MatchString.end(0) != len( LineDetails[1]): EdkLogger.error( 'Image Definition File Parser', FORMAT_INVALID, 'The Image token name %s defined in Idf file %s contains the invalid character.' % (LineDetails[1], File.Path)) if LineDetails[1] not in self.ImageIDList: self.ImageIDList.append(LineDetails[1]) else: EdkLogger.error( "Image Definition File Parser", PARSER_ERROR, 'The %s in Line %s of File %s is already defined.' % (LineDetails[1], LineNo, File.Path)) if Len == 4: ImageFile = ImageFileObject(LineDetails[Len - 1], LineDetails[1], True) else: ImageFile = ImageFileObject(LineDetails[Len - 1], LineDetails[1], False) ImageFileList.append(ImageFile) if ImageFileList: self.ImageFilesDict[File] = ImageFileList
# # Get Language definition # def GetLangDef(self, File, Line): Lang = distutils.util.split_quoted((Line.split(u"//")[0])) if len(Lang) != 3: try: FileIn = self.OpenUniFile(LongFilePath(File.Path)) except UnicodeError, X: EdkLogger.error("build", FILE_READ_FAILURE, "File read failure: %s" % str(X), ExtraData=File) except: EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=File) LineNo = GetLineNo(FileIn, Line, False) EdkLogger.error( "Unicode File Parser", PARSER_ERROR, "Wrong language definition", ExtraData= """%s\n\t*Correct format is like '#langdef en-US "English"'""" % Line, File=File, Line=LineNo) else: LangName = GetLanguageCode(Lang[1], self.IsCompatibleMode, self.File) LangPrintName = Lang[2] IsLangInDef = False