CommandString = "\n\t".join(self.CommandList)\r
return "%s : %s\n\t%s" % (DestString, SourceString, CommandString)\r
\r
- def Instantiate(self, Macros={}):\r
+ def Instantiate(self, Macros = None):\r
+ if Macros is None:\r
+ Macros = {}\r
NewRuleObject = copy.copy(self)\r
NewRuleObject.BuildTargets = {}\r
NewRuleObject.DestFileList = []\r
def GetRemoveDirectoryCommand(self, DirList):\r
return [self._RD_TEMPLATE_[self._FileType] % {'dir':Dir} for Dir in DirList]\r
\r
- def PlaceMacro(self, Path, MacroDefinitions={}):\r
+ def PlaceMacro(self, Path, MacroDefinitions=None):\r
if Path.startswith("$("):\r
return Path\r
else:\r
+ if MacroDefinitions is None:\r
+ MacroDefinitions = {}\r
PathLength = len(Path)\r
for MacroName in MacroDefinitions:\r
MacroValue = MacroDefinitions[MacroName]\r
\r
# This acts like the main() function for the script, unless it is 'import'ed into another script.\r
if __name__ == '__main__':\r
- pass\r
\ No newline at end of file
+ pass\r
raise BadExpression(ERR_STRING_EXPR % Operator)\r
\r
\r
- def __init__(self, Expression, PcdDataType, SymbolTable = {}):\r
+ def __init__(self, Expression, PcdDataType, SymbolTable = None):\r
+ if SymbolTable is None:\r
+ SymbolTable = {}\r
super(RangeExpression, self).__init__(self, Expression, PcdDataType, SymbolTable)\r
self._NoProcess = False\r
if not isinstance(Expression, type('')):\r
#\r
# @retval NewList A new string list whose macros are replaced\r
#\r
-def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False):\r
+def ReplaceMacros(StringList, MacroDefinitions=None, SelfReplacement=False):\r
NewList = []\r
+ if MacroDefinitions is None:\r
+ MacroDefinitions = {}\r
for String in StringList:\r
if isinstance(String, type('')):\r
NewList.append(ReplaceMacro(String, MacroDefinitions, SelfReplacement))\r
#\r
# @retval string The string whose macros are replaced\r
#\r
-def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement=False, RaiseError=False):\r
+def ReplaceMacro(String, MacroDefinitions=None, SelfReplacement=False, RaiseError=False):\r
LastString = String\r
+ if MacroDefinitions is None:\r
+ MacroDefinitions = {}\r
while String and MacroDefinitions:\r
MacroUsed = GlobalData.gMacroRefPattern.findall(String)\r
# no macro found in String, stop replacing\r
#\r
# @retval Path Formatted path\r
#\r
-def NormPath(Path, Defines={}):\r
+def NormPath(Path, Defines=None):\r
IsRelativePath = False\r
if Path:\r
if Path[0] == '.':\r
# @param Dict dictionary contains macro and its value\r
# @retval string Generated file name\r
#\r
- def GenFfs (self, FvName, Dict = {}, IsMakefile = False):\r
+ def GenFfs (self, FvName, Dict = None, IsMakefile = False):\r
+ if Dict is None:\r
+ Dict = {}\r
Buffer = BytesIO()\r
if self.AprioriType == "PEI":\r
AprioriFileGuid = PEI_APRIORI_GUID\r
# @param Dict dictionary contains macro and its value\r
# @retval tuple (Generated file name, section alignment)\r
#\r
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):\r
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False):\r
\r
if FfsInf is not None:\r
self.CompType = FfsInf.__ExtendMacro__(self.CompType)\r
SectAlign = []\r
Index = 0\r
MaxAlign = None\r
+ if Dict is None:\r
+ Dict = {}\r
for Sect in self.SectionList:\r
Index = Index + 1\r
SecIndex = '%s.%d' %(SecNum, Index)\r
# @param Dict dictionary contains macro and its value\r
# @retval tuple (Generated file name list, section alignment)\r
#\r
- def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}, IsMakefile = False):\r
+ def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = None, IsMakefile = False):\r
#\r
# Prepare the parameter of GenSection\r
#\r
+ if Dict is None:\r
+ Dict = {}\r
if FfsFile is not None:\r
self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.SectFileName)\r
self.SectFileName = GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict, FfsFile.CurrentArch)\r
# @param Dict dictionary contains macro and its value\r
# @retval tuple (Generated file name list, section alignment)\r
#\r
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False) :\r
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False) :\r
\r
if self.FileName is not None and self.FileName.startswith('PCD('):\r
self.FileName = GenFdsGlobalVariable.GetPcdValue(self.FileName)\r
\r
"""If the file name was pointed out, add it in FileList"""\r
FileList = []\r
+ if Dict is None:\r
+ Dict = {}\r
if Filename is not None:\r
Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)\r
# check if the path is absolute or relative\r
# @param FvParentAddr Parent Fv base address\r
# @retval string Generated FFS file name\r
#\r
- def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):\r
+ def GenFfs(self, Dict = None, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):\r
\r
if self.NameGuid and self.NameGuid.startswith('PCD('):\r
PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)\r
if not os.path.exists(OutputDir):\r
os.makedirs(OutputDir)\r
\r
+ if Dict is None:\r
+ Dict = {}\r
+\r
Dict.update(self.DefineVarDict)\r
SectionAlignments = None\r
if self.FvName:\r
# @param FvParentAddr Parent Fv base address\r
# @retval string Generated FFS file name\r
#\r
- def GenFfs(self, Dict = {}, FvChildAddr = [], FvParentAddr=None, IsMakefile=False, FvName=None):\r
+ def GenFfs(self, Dict = None, FvChildAddr = [], FvParentAddr=None, IsMakefile=False, FvName=None):\r
#\r
# Parse Inf file get Module related information\r
#\r
-\r
+ if Dict is None:\r
+ Dict = {}\r
self.__InfParse__(Dict, IsGenFfs=True)\r
Arch = self.GetCurrentArch()\r
SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName);\r
# @param MacroDict macro value pair\r
# @retval string Generated FV file path\r
#\r
- def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', MacroDict = {}, Flag=False):\r
+ def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', MacroDict = None, Flag=False):\r
if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:\r
return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv']\r
+ if MacroDict is None:\r
+ MacroDict = {}\r
\r
#\r
# Check whether FV in Capsule is in FD flash region.\r
# @param Dict dictionary contains macro and its value\r
# @retval tuple (Generated file name, section alignment)\r
#\r
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):\r
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False):\r
\r
OutputFileList = []\r
+ if Dict is None:\r
+ Dict = {}\r
if self.FvFileType is not None:\r
FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FvFileType, self.FvFileExtension)\r
if IsSect :\r
# @param MacroDict Dictionary that contains macro value pair\r
#\r
@staticmethod\r
- def MacroExtend (Str, MacroDict={}, Arch=DataType.TAB_COMMON):\r
+ def MacroExtend (Str, MacroDict=None, Arch=DataType.TAB_COMMON):\r
if Str is None:\r
return None\r
\r
# @param Dict dictionary contains macro and its value\r
# @retval tuple (Generated file name, section alignment)\r
#\r
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile=False):\r
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile=False):\r
#\r
# Generate all section\r
#\r
SectAlign = []\r
Index = 0\r
MaxAlign = None\r
+ if Dict is None:\r
+ Dict = {}\r
if self.FvAddr != []:\r
FvAddrIsSet = True\r
else:\r
# @param Dict dictionary contains macro and value pair\r
# @retval string Generated FFS file name\r
#\r
- def GenFfs(self, Dict = {}, IsMakefile=False):\r
+ def GenFfs(self, Dict = None, IsMakefile=False):\r
+\r
+ if Dict is None:\r
+ Dict = {}\r
\r
if self.FileName is not None:\r
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
# @retval string Generated FV file path\r
#\r
\r
- def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, MacroDict={}, Flag=False):\r
+ def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, MacroDict=None, Flag=False):\r
Size = self.Size\r
+ if MacroDict is None:\r
+ MacroDict = {}\r
if not Flag:\r
GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)\r
GenFdsGlobalVariable.InfLogger(" Region Size = 0x%X" % Size)\r
# @param FfsInf FfsInfStatement object that contains this section data\r
# @param Dict dictionary contains macro and its value\r
#\r
- def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = {}):\r
+ def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = None):\r
pass\r
\r
## GetFileList() method\r
# @param Dict dictionary contains macro and its value\r
# @retval tuple (Generated file name, section alignment)\r
#\r
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):\r
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile = False):\r
#\r
# Prepare the parameter of GenSection\r
#\r
if self.StringData is not None :\r
NameString = self.StringData\r
elif self.FileName is not None:\r
+ if Dict is None:\r
+ Dict = {}\r
FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)\r
FileObj = open(FileNameStr, 'r')\r
# @param Dict dictionary contains macro and its value\r
# @retval tuple (Generated file name, section alignment)\r
#\r
- def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):\r
+ def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile = False):\r
#\r
# Prepare the parameter of GenSection\r
#\r
if self.StringData:\r
StringData = self.StringData\r
elif self.FileName:\r
+ if Dict is None:\r
+ Dict = {}\r
FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)\r
FileObj = open(FileNameStr, 'r')\r