]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/UPT/Parser/InfParser.py
Sync BaseTool trunk (version r2423) into EDKII BaseTools. The change mainly includes:
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Parser / InfParser.py
CommitLineData
4234283c
LG
1## @file\r
2# This file contained the parser for INF file\r
3#\r
4# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
5#\r
6# This program and the accompanying materials are licensed and made available \r
7# under the terms and conditions of the BSD License which accompanies this \r
8# distribution. The full text of the license may be found at \r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15'''\r
16InfParser\r
17'''\r
18\r
19##\r
20# Import Modules\r
21#\r
22import re\r
23import os\r
24from copy import deepcopy\r
25\r
26from Library.String import GetSplitValueList\r
27from Library.String import ConvertSpecialChar\r
28from Library.Misc import ProcessLineExtender\r
2bcc713e 29from Library.Misc import ProcessEdkComment\r
4234283c
LG
30from Library.Parsing import NormPath\r
31from Library.ParserValidate import IsValidInfMoudleTypeList\r
32from Library.ParserValidate import IsValidArch\r
33from Library import DataType as DT\r
34from Library import GlobalData\r
35\r
36import Logger.Log as Logger\r
37from Logger import StringTable as ST\r
38from Logger.ToolError import FORMAT_INVALID\r
39from Logger.ToolError import FILE_READ_FAILURE\r
40from Logger.ToolError import PARSER_ERROR\r
41\r
42from Object.Parser.InfCommonObject import InfSectionCommonDef\r
43from Parser.InfSectionParser import InfSectionParser\r
44from Parser.InfParserMisc import gINF_SECTION_DEF\r
45from Parser.InfParserMisc import IsBinaryInf\r
46\r
47## OpenInfFile\r
48#\r
49#\r
50def OpenInfFile(Filename):\r
51 FileLinesList = []\r
52 \r
53 try:\r
54 FInputfile = open(Filename, "rb", 0)\r
55 try:\r
56 FileLinesList = FInputfile.readlines()\r
57 except BaseException:\r
58 Logger.Error("InfParser", \r
59 FILE_READ_FAILURE, \r
60 ST.ERR_FILE_OPEN_FAILURE,\r
61 File=Filename)\r
62 finally:\r
63 FInputfile.close()\r
64 except BaseException:\r
65 Logger.Error("InfParser", \r
66 FILE_READ_FAILURE, \r
67 ST.ERR_FILE_OPEN_FAILURE,\r
68 File=Filename)\r
69 \r
70 return FileLinesList\r
71\r
72## InfParser\r
73#\r
74# This class defined the structure used in InfParser object\r
75#\r
76# @param InfObject: Inherited from InfSectionParser class\r
77# @param Filename: Input value for Filename of INF file, default is \r
78# None\r
79# @param WorkspaceDir: Input value for current workspace directory, \r
80# default is None\r
81#\r
82class InfParser(InfSectionParser):\r
83\r
84 def __init__(self, Filename = None, WorkspaceDir = None):\r
85 \r
86 #\r
87 # Call parent class construct function\r
88 #\r
89 super(InfParser, self).__init__()\r
90 \r
91 self.WorkspaceDir = WorkspaceDir\r
92 self.SupArchList = DT.ARCH_LIST\r
93 self.EventList = []\r
94 self.HobList = []\r
95 self.BootModeList = []\r
96\r
97 #\r
98 # Load Inf file if filename is not None\r
99 #\r
100 if Filename != None:\r
101 self.ParseInfFile(Filename)\r
102\r
103 ## Parse INF file\r
104 #\r
105 # Parse the file if it exists\r
106 #\r
107 # @param Filename: Input value for filename of INF file\r
108 #\r
109 def ParseInfFile(self, Filename):\r
110 \r
111 Filename = NormPath(Filename)\r
112 (Path, Name) = os.path.split(Filename)\r
113 self.FullPath = Filename\r
114 self.RelaPath = Path\r
115 self.FileName = Name\r
116 GlobalData.gINF_MODULE_DIR = Path\r
117 GlobalData.gINF_MODULE_NAME = self.FullPath\r
118 GlobalData.gIS_BINARY_INF = False\r
119 #\r
120 # Initialize common data\r
121 #\r
122 LineNo = 0\r
123 CurrentSection = DT.MODEL_UNKNOWN \r
124 SectionLines = []\r
125 \r
126 #\r
127 # Flags\r
128 #\r
129 HeaderCommentStart = False \r
130 HeaderCommentEnd = False\r
131 \r
132 #\r
133 # While Section ends. parse whole section contents.\r
134 #\r
135 NewSectionStartFlag = False\r
136 FirstSectionStartFlag = False\r
137 \r
138 #\r
139 # Parse file content\r
140 #\r
141 CommentBlock = []\r
142 \r
143 #\r
144 # Variables for Event/Hob/BootMode\r
145 #\r
146 self.EventList = []\r
147 self.HobList = []\r
148 self.BootModeList = []\r
149 SectionType = ''\r
150 \r
151 FileLinesList = OpenInfFile (Filename)\r
152 \r
153 #\r
154 # One INF file can only has one [Defines] section.\r
155 #\r
156 DefineSectionParsedFlag = False\r
157 \r
158 #\r
159 # Convert special characters in lines to space character.\r
160 #\r
161 FileLinesList = ConvertSpecialChar(FileLinesList)\r
162 \r
163 #\r
164 # Process Line Extender\r
165 #\r
166 FileLinesList = ProcessLineExtender(FileLinesList)\r
167 \r
2bcc713e
LG
168 #\r
169 # Process EdkI INF style comment if found\r
170 #\r
171 OrigLines = [Line for Line in FileLinesList]\r
172 FileLinesList, EdkCommentStartPos = ProcessEdkComment(FileLinesList)\r
173 \r
4234283c
LG
174 #\r
175 # Judge whether the INF file is Binary INF or not\r
176 #\r
177 if IsBinaryInf(FileLinesList):\r
178 GlobalData.gIS_BINARY_INF = True\r
179 \r
180 InfSectionCommonDefObj = None\r
181 \r
182 for Line in FileLinesList:\r
183 LineNo = LineNo + 1\r
184 Line = Line.strip()\r
185 if (LineNo < len(FileLinesList) - 1):\r
186 NextLine = FileLinesList[LineNo].strip()\r
187 \r
188 #\r
189 # blank line\r
190 #\r
191 if (Line == '' or not Line) and LineNo == len(FileLinesList):\r
192 LastSectionFalg = True\r
193\r
194 #\r
195 # check whether file header comment section started\r
196 #\r
197 if Line.startswith(DT.TAB_SPECIAL_COMMENT) and \\r
198 (Line.find(DT.TAB_HEADER_COMMENT) > -1) and \\r
199 not HeaderCommentStart:\r
200 if CurrentSection != DT.MODEL_UNKNOWN:\r
201 Logger.Error("Parser", \r
202 PARSER_ERROR, \r
203 ST.ERR_INF_PARSER_HEADER_FILE, \r
204 File=Filename, \r
205 Line=LineNo, \r
206 RaiseError = Logger.IS_RAISE_ERROR)\r
207 else:\r
208 CurrentSection = DT.MODEL_META_DATA_FILE_HEADER\r
209 #\r
210 # Append the first line to section lines.\r
211 #\r
212 SectionLines.append((Line, LineNo))\r
213 HeaderCommentStart = True\r
214 continue \r
215 \r
216 #\r
217 # Collect Header content.\r
218 #\r
219 if (Line.startswith(DT.TAB_COMMENT_SPLIT) and CurrentSection == DT.MODEL_META_DATA_FILE_HEADER) and\\r
220 HeaderCommentStart and not Line.startswith(DT.TAB_SPECIAL_COMMENT) and not\\r
221 HeaderCommentEnd and NextLine != '':\r
222 SectionLines.append((Line, LineNo))\r
223 continue\r
224 #\r
225 # Header content end\r
226 #\r
227 if (Line.startswith(DT.TAB_SPECIAL_COMMENT) or not Line.strip().startswith("#")) and HeaderCommentStart \\r
228 and not HeaderCommentEnd:\r
229 SectionLines.append((Line, LineNo))\r
230 HeaderCommentStart = False\r
231 #\r
232 # Call Header comment parser.\r
233 #\r
234 self.InfHeaderParser(SectionLines, self.InfHeader, self.FileName)\r
235 SectionLines = []\r
236 HeaderCommentEnd = True \r
237 continue \r
238 \r
239 #\r
240 # Find a new section tab\r
241 # Or at the last line of INF file, \r
242 # need to process the last section.\r
243 #\r
244 LastSectionFalg = False\r
245 if LineNo == len(FileLinesList):\r
246 LastSectionFalg = True\r
247 \r
248 if Line.startswith(DT.TAB_COMMENT_SPLIT) and not Line.startswith(DT.TAB_SPECIAL_COMMENT):\r
249 SectionLines.append((Line, LineNo))\r
250 if not LastSectionFalg:\r
251 continue\r
252 \r
253 #\r
254 # Encountered a section. start with '[' and end with ']'\r
255 #\r
256 if (Line.startswith(DT.TAB_SECTION_START) and \\r
257 Line.find(DT.TAB_SECTION_END) > -1) or LastSectionFalg: \r
258 if not LastSectionFalg:\r
259 #\r
260 # check to prevent '#' inside section header\r
261 #\r
262 HeaderContent = Line[1:Line.find(DT.TAB_SECTION_END)]\r
263 if HeaderContent.find(DT.TAB_COMMENT_SPLIT) != -1:\r
264 Logger.Error("InfParser", \r
265 FORMAT_INVALID,\r
266 ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,\r
267 File=self.FullPath,\r
268 Line=LineNo, \r
269 ExtraData=Line) \r
270 \r
271 #\r
272 # Keep last time section header content for section parser\r
273 # usage.\r
274 #\r
275 self.LastSectionHeaderContent = deepcopy(self.SectionHeaderContent)\r
276 \r
277 #\r
278 # TailComments in section define.\r
279 #\r
280 TailComments = ''\r
281 CommentIndex = Line.find(DT.TAB_COMMENT_SPLIT)\r
282 if CommentIndex > -1:\r
283 TailComments = Line[CommentIndex:]\r
284 Line = Line[:CommentIndex]\r
285 \r
286 InfSectionCommonDefObj = InfSectionCommonDef()\r
287 if TailComments != '':\r
288 InfSectionCommonDefObj.SetTailComments(TailComments)\r
289 if CommentBlock != '':\r
290 InfSectionCommonDefObj.SetHeaderComments(CommentBlock)\r
291 CommentBlock = []\r
292 #\r
293 # Call section parser before section header parer to avoid encounter EDKI INF file\r
294 #\r
295 if CurrentSection == DT.MODEL_META_DATA_DEFINE:\r
296 DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection, \r
297 DefineSectionParsedFlag, SectionLines, \r
298 InfSectionCommonDefObj, LineNo)\r
299 #\r
300 # Compare the new section name with current\r
301 #\r
302 self.SectionHeaderParser(Line, self.FileName, LineNo)\r
303 \r
304 self._CheckSectionHeaders(Line, LineNo)\r
305\r
306 SectionType = _ConvertSecNameToType(self.SectionHeaderContent[0][0])\r
307 \r
308 if not FirstSectionStartFlag:\r
309 CurrentSection = SectionType\r
310 FirstSectionStartFlag = True\r
311 else:\r
312 NewSectionStartFlag = True\r
313 else:\r
314 SectionLines.append((Line, LineNo))\r
315 continue\r
316 \r
317 if LastSectionFalg:\r
318 SectionLines, CurrentSection = self._ProcessLastSection(SectionLines, Line, LineNo, CurrentSection)\r
319 \r
320 #\r
321 # End of section content collect.\r
322 # Parser the section content collected previously.\r
323 # \r
324 if NewSectionStartFlag or LastSectionFalg:\r
325 if CurrentSection != DT.MODEL_META_DATA_DEFINE or \\r
326 (LastSectionFalg and CurrentSection == DT.MODEL_META_DATA_DEFINE): \r
327 DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection, \r
328 DefineSectionParsedFlag, SectionLines, \r
329 InfSectionCommonDefObj, LineNo)\r
330 \r
331 CurrentSection = SectionType\r
332 #\r
333 # Clear section lines\r
334 #\r
335 SectionLines = [] \r
336 #\r
337 # End of for\r
338 #\r
339 #\r
340 # Found the first section, No file header.\r
341 #\r
342 if not DefineSectionParsedFlag:\r
343 Logger.Error("InfParser", \r
344 FORMAT_INVALID, \r
345 ST.ERR_INF_PARSER_HEADER_MISSGING, \r
346 File=self.FullPath)\r
347 \r
2bcc713e
LG
348 #\r
349 # EDKII INF should not have EDKI style comment\r
350 #\r
351 if EdkCommentStartPos != -1:\r
352 Logger.Error("InfParser", \r
353 FORMAT_INVALID, \r
354 ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII, \r
355 File=self.FullPath,\r
356 Line=EdkCommentStartPos + 1,\r
357 ExtraData=OrigLines[EdkCommentStartPos])\r
358 \r
4234283c
LG
359 #\r
360 # extract [Event] [Hob] [BootMode] sections \r
361 # \r
362 self._ExtractEventHobBootMod(FileLinesList)\r
363 \r
364 ## _CheckSectionHeaders\r
365 #\r
366 #\r
367 def _CheckSectionHeaders(self, Line, LineNo):\r
368 if len(self.SectionHeaderContent) == 0:\r
369 Logger.Error("InfParser", \r
370 FORMAT_INVALID,\r
371 ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,\r
372 File=self.FullPath,\r
373 Line=LineNo, ExtraData=Line)\r
374 else:\r
375 for SectionItem in self.SectionHeaderContent:\r
376 ArchList = []\r
377 #\r
378 # Not cover Depex/UserExtension section header \r
379 # check.\r
380 #\r
381 if SectionItem[0].strip().upper() == DT.TAB_INF_FIXED_PCD.upper() or \\r
382 SectionItem[0].strip().upper() == DT.TAB_INF_PATCH_PCD.upper() or \\r
383 SectionItem[0].strip().upper() == DT.TAB_INF_PCD_EX.upper() or \\r
384 SectionItem[0].strip().upper() == DT.TAB_INF_PCD.upper() or \\r
385 SectionItem[0].strip().upper() == DT.TAB_INF_FEATURE_PCD.upper():\r
386 ArchList = GetSplitValueList(SectionItem[1].strip(), ' ')\r
387 else:\r
388 ArchList = [SectionItem[1].strip()]\r
389 \r
390 for Arch in ArchList:\r
391 if (not IsValidArch(Arch)) and \\r
392 (SectionItem[0].strip().upper() != DT.TAB_DEPEX.upper()) and \\r
393 (SectionItem[0].strip().upper() != DT.TAB_USER_EXTENSIONS.upper()) and \\r
394 (SectionItem[0].strip().upper() != DT.TAB_COMMON_DEFINES.upper()):\r
395 Logger.Error("InfParser", \r
396 FORMAT_INVALID,\r
397 ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[1]), \r
398 File=self.FullPath,\r
399 Line=LineNo, ExtraData=Line)\r
400 #\r
401 # Check if the ModuleType is valid\r
402 #\r
403 ChkModSectionList = ['LIBRARYCLASSES']\r
404 if (self.SectionHeaderContent[0][0].upper() in ChkModSectionList):\r
405 if SectionItem[2].strip().upper():\r
406 MoudleTypeList = GetSplitValueList(\r
407 SectionItem[2].strip().upper())\r
408 if (not IsValidInfMoudleTypeList(MoudleTypeList)):\r
409 Logger.Error("InfParser",\r
410 FORMAT_INVALID,\r
411 ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[2]),\r
412 File=self.FullPath, Line=LineNo,\r
413 ExtraData=Line)\r
414 \r
415 ## _CallSectionParsers\r
416 #\r
417 #\r
418 def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag, \r
419 SectionLines, InfSectionCommonDefObj, LineNo):\r
420 if CurrentSection == DT.MODEL_META_DATA_DEFINE:\r
421 if not DefineSectionParsedFlag:\r
422 self.InfDefineParser(SectionLines,\r
423 self.InfDefSection,\r
424 self.FullPath,\r
425 InfSectionCommonDefObj)\r
426 DefineSectionParsedFlag = True\r
427 else:\r
428 Logger.Error("Parser", \r
429 PARSER_ERROR, \r
430 ST.ERR_INF_PARSER_MULTI_DEFINE_SECTION, \r
431 File=self.FullPath, \r
432 RaiseError = Logger.IS_RAISE_ERROR)\r
433 \r
434 elif CurrentSection == DT.MODEL_META_DATA_BUILD_OPTION:\r
435 self.InfBuildOptionParser(SectionLines,\r
436 self.InfBuildOptionSection,\r
437 self.FullPath)\r
438 \r
439 elif CurrentSection == DT.MODEL_EFI_LIBRARY_CLASS:\r
440 self.InfLibraryParser(SectionLines,\r
441 self.InfLibraryClassSection,\r
442 self.FullPath)\r
443 \r
444 elif CurrentSection == DT.MODEL_META_DATA_PACKAGE:\r
445 self.InfPackageParser(SectionLines,\r
446 self.InfPackageSection,\r
447 self.FullPath)\r
448 #\r
449 # [Pcd] Sections, put it together\r
450 #\r
451 elif CurrentSection == DT.MODEL_PCD_FIXED_AT_BUILD or \\r
452 CurrentSection == DT.MODEL_PCD_PATCHABLE_IN_MODULE or \\r
453 CurrentSection == DT.MODEL_PCD_FEATURE_FLAG or \\r
454 CurrentSection == DT.MODEL_PCD_DYNAMIC_EX or \\r
455 CurrentSection == DT.MODEL_PCD_DYNAMIC:\r
456 self.InfPcdParser(SectionLines,\r
457 self.InfPcdSection,\r
458 self.FullPath)\r
459 \r
460 elif CurrentSection == DT.MODEL_EFI_SOURCE_FILE:\r
461 self.InfSourceParser(SectionLines,\r
462 self.InfSourcesSection,\r
463 self.FullPath)\r
464 \r
465 elif CurrentSection == DT.MODEL_META_DATA_USER_EXTENSION:\r
466 self.InfUserExtensionParser(SectionLines,\r
467 self.InfUserExtensionSection,\r
468 self.FullPath)\r
469 \r
470 elif CurrentSection == DT.MODEL_EFI_PROTOCOL:\r
471 self.InfProtocolParser(SectionLines,\r
472 self.InfProtocolSection,\r
473 self.FullPath)\r
474 \r
475 elif CurrentSection == DT.MODEL_EFI_PPI:\r
476 self.InfPpiParser(SectionLines,\r
477 self.InfPpiSection,\r
478 self.FullPath)\r
479 \r
480 elif CurrentSection == DT.MODEL_EFI_GUID:\r
481 self.InfGuidParser(SectionLines,\r
482 self.InfGuidSection,\r
483 self.FullPath)\r
484 \r
485 elif CurrentSection == DT.MODEL_EFI_DEPEX:\r
486 self.InfDepexParser(SectionLines,\r
487 self.InfDepexSection,\r
488 self.FullPath)\r
489 \r
490 elif CurrentSection == DT.MODEL_EFI_BINARY_FILE:\r
491 self.InfBinaryParser(SectionLines,\r
492 self.InfBinariesSection,\r
493 self.FullPath)\r
494 #\r
495 # Unknown section type found, raise error.\r
496 #\r
497 else:\r
498 if len(self.SectionHeaderContent) >= 1:\r
499 Logger.Error("Parser", \r
500 PARSER_ERROR, \r
501 ST.ERR_INF_PARSER_UNKNOWN_SECTION, \r
502 File=self.FullPath, Line=LineNo, \r
503 RaiseError = Logger.IS_RAISE_ERROR)\r
504 else:\r
505 Logger.Error("Parser", \r
506 PARSER_ERROR, \r
507 ST.ERR_INF_PARSER_NO_SECTION_ERROR, \r
508 File=self.FullPath, Line=LineNo, \r
509 RaiseError = Logger.IS_RAISE_ERROR)\r
510 \r
511 return DefineSectionParsedFlag \r
512 \r
513 def _ExtractEventHobBootMod(self, FileLinesList):\r
514 SpecialSectionStart = False\r
515 CheckLocation = False\r
516 GFindSpecialCommentRe = \\r
517 re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)\r
518 GFindNewSectionRe2 = \\r
519 re.compile(r"""#?(\s*)\[(.*?)\](.*)""", re.DOTALL)\r
520 LineNum = 0\r
521 Element = []\r
522 for Line in FileLinesList:\r
523 Line = Line.strip()\r
524 LineNum += 1\r
525 MatchObject = GFindSpecialCommentRe.search(Line)\r
526 if MatchObject:\r
527 SpecialSectionStart = True\r
528 Element = []\r
529 if MatchObject.group(1).upper().startswith("EVENT"):\r
530 List = self.EventList\r
531 elif MatchObject.group(1).upper().startswith("HOB"):\r
532 List = self.HobList\r
533 elif MatchObject.group(1).upper().startswith("BOOTMODE"):\r
534 List = self.BootModeList\r
535 else:\r
536 SpecialSectionStart = False\r
537 CheckLocation = False\r
538 if SpecialSectionStart:\r
539 Element.append([Line, LineNum])\r
540 List.append(Element)\r
541 else:\r
542 #\r
543 # if currently in special section, try to detect end of current section\r
544 #\r
545 MatchObject = GFindNewSectionRe2.search(Line)\r
546 if SpecialSectionStart:\r
547 if MatchObject:\r
548 SpecialSectionStart = False\r
549 CheckLocation = False\r
550 Element = []\r
551 elif not Line:\r
552 SpecialSectionStart = False\r
553 CheckLocation = True\r
554 Element = [] \r
555 else:\r
556 if not Line.startswith(DT.TAB_COMMENT_SPLIT):\r
557 Logger.Warn("Parser", \r
558 ST.WARN_SPECIAL_SECTION_LOCATION_WRONG, \r
559 File=self.FullPath, Line=LineNum)\r
560 SpecialSectionStart = False\r
561 CheckLocation = False\r
562 Element = []\r
563 else:\r
564 Element.append([Line, LineNum]) \r
565 else:\r
566 if CheckLocation:\r
567 if MatchObject:\r
568 CheckLocation = False\r
569 elif Line:\r
570 Logger.Warn("Parser", \r
571 ST.WARN_SPECIAL_SECTION_LOCATION_WRONG, \r
572 File=self.FullPath, Line=LineNum) \r
573 CheckLocation = False\r
574 \r
575 if len(self.BootModeList) >= 1:\r
576 self.InfSpecialCommentParser(self.BootModeList, \r
577 self.InfSpecialCommentSection, \r
578 self.FileName, \r
579 DT.TYPE_BOOTMODE_SECTION)\r
580 \r
581 if len(self.EventList) >= 1:\r
582 self.InfSpecialCommentParser(self.EventList, \r
583 self.InfSpecialCommentSection,\r
584 self.FileName, \r
585 DT.TYPE_EVENT_SECTION)\r
586 \r
587 if len(self.HobList) >= 1:\r
588 self.InfSpecialCommentParser(self.HobList, \r
589 self.InfSpecialCommentSection, \r
590 self.FileName, \r
591 DT.TYPE_HOB_SECTION)\r
592 ## _ProcessLastSection\r
593 #\r
594 #\r
595 def _ProcessLastSection(self, SectionLines, Line, LineNo, CurrentSection):\r
596 #\r
597 # The last line is a section header. will discard it.\r
598 #\r
599 if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1): \r
600 SectionLines.append((Line, LineNo))\r
601 \r
602 if len(self.SectionHeaderContent) >= 1:\r
603 TemSectionName = self.SectionHeaderContent[0][0].upper()\r
604 if TemSectionName.upper() not in gINF_SECTION_DEF.keys():\r
605 Logger.Error("InfParser", \r
606 FORMAT_INVALID, \r
607 ST.ERR_INF_PARSER_UNKNOWN_SECTION, \r
608 File=self.FullPath, \r
609 Line=LineNo, \r
610 ExtraData=Line,\r
611 RaiseError = Logger.IS_RAISE_ERROR\r
612 ) \r
613 else:\r
614 CurrentSection = gINF_SECTION_DEF[TemSectionName]\r
615 self.LastSectionHeaderContent = self.SectionHeaderContent\r
616 \r
617 return SectionLines, CurrentSection\r
618\r
619## _ConvertSecNameToType\r
620#\r
621#\r
622def _ConvertSecNameToType(SectionName): \r
623 SectionType = ''\r
624 if SectionName.upper() not in gINF_SECTION_DEF.keys():\r
625 SectionType = DT.MODEL_UNKNOWN \r
626 else:\r
627 SectionType = gINF_SECTION_DEF[SectionName.upper()] \r
628 \r
629 return SectionType \r
630