from Common.Expression import *\r
from CommonDataClass.Exceptions import *\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
-\r
+from collections import defaultdict\r
from MetaFileTable import MetaFileStorage\r
from MetaFileCommentParser import CheckInfComment\r
\r
self._FileDir = self.MetaFile.Dir\r
self._Defines = {}\r
self._FileLocalMacros = {}\r
- self._SectionsMacroDict = {}\r
+ self._SectionsMacroDict = defaultdict(dict)\r
\r
# for recursive parsing\r
self._Owner = [Owner]\r
def _ConstructSectionMacroDict(self, Name, Value):\r
ScopeKey = [(Scope[0], Scope[1],Scope[2]) for Scope in self._Scope]\r
ScopeKey = tuple(ScopeKey)\r
- SectionDictKey = self._SectionType, ScopeKey\r
#\r
# DecParser SectionType is a list, will contain more than one item only in Pcd Section\r
# As Pcd section macro usage is not alllowed, so here it is safe\r
#\r
if type(self) == DecParser:\r
SectionDictKey = self._SectionType[0], ScopeKey\r
- if SectionDictKey not in self._SectionsMacroDict:\r
- self._SectionsMacroDict[SectionDictKey] = {}\r
- SectionLocalMacros = self._SectionsMacroDict[SectionDictKey]\r
- SectionLocalMacros[Name] = Value\r
+ else:\r
+ SectionDictKey = self._SectionType, ScopeKey\r
+\r
+ self._SectionsMacroDict[SectionDictKey][Name] = Value\r
\r
## Get section Macros that are applicable to current line, which may come from other sections \r
## that share the same name while scope is wider\r
self._SubsectionType = MODEL_UNKNOWN\r
self._SubsectionName = ''\r
self._Owner[-1] = -1\r
- OwnerId = {}\r
+ OwnerId.clear()\r
continue\r
# subsection header\r
elif Line[0] == TAB_OPTION_START and Line[-1] == TAB_OPTION_END:\r
self._DirectiveEvalStack = []\r
self._FileWithError = self.MetaFile\r
self._FileLocalMacros = {}\r
- self._SectionsMacroDict = {}\r
+ self._SectionsMacroDict.clear()\r
GlobalData.gPlatformDefines = {}\r
\r
# Get all macro and PCD which has straitforward value\r