BaseTools: dont make iterator into list if not needed

functions (like join) can use the iterator just as easily.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Carsey, Jaben 2018-04-28 06:32:54 +08:00 committed by Yonghong Zhu
parent 4d601fc6b1
commit 8252e6bf2d
10 changed files with 34 additions and 34 deletions

View File

@ -460,7 +460,7 @@ class WorkspaceAutoGen(AutoGen):
'build', 'build',
FORMAT_INVALID, FORMAT_INVALID,
"Building modules from source INFs, following PCD use %s and %s access method. It must be corrected to use only one access method." % (i, j), "Building modules from source INFs, following PCD use %s and %s access method. It must be corrected to use only one access method." % (i, j),
ExtraData="%s" % '\n\t'.join([str(P[1]+'.'+P[0]) for P in Intersections]) ExtraData="%s" % '\n\t'.join(str(P[1]+'.'+P[0]) for P in Intersections)
) )
# #
@ -2295,7 +2295,7 @@ class PlatformAutoGen(AutoGen):
# #
for Item in LibraryList: for Item in LibraryList:
if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1: if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1:
ErrorMessage = "\tconsumed by " + "\n\tconsumed by ".join([str(L) for L in ConsumedByList[Item]]) ErrorMessage = "\tconsumed by " + "\n\tconsumed by ".join(str(L) for L in ConsumedByList[Item])
EdkLogger.error("build", BUILD_ERROR, 'Library [%s] with constructors has a cycle' % str(Item), EdkLogger.error("build", BUILD_ERROR, 'Library [%s] with constructors has a cycle' % str(Item),
ExtraData=ErrorMessage, File=self.MetaFile) ExtraData=ErrorMessage, File=self.MetaFile)
if Item not in SortedLibraryList: if Item not in SortedLibraryList:
@ -2415,7 +2415,7 @@ class PlatformAutoGen(AutoGen):
if Sku.VariableGuid == '': continue if Sku.VariableGuid == '': continue
Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList, self.MetaFile.Path) Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList, self.MetaFile.Path)
if Sku.VariableGuidValue is None: if Sku.VariableGuidValue is None:
PackageList = "\n\t".join([str(P) for P in self.PackageList]) PackageList = "\n\t".join(str(P) for P in self.PackageList)
EdkLogger.error( EdkLogger.error(
'build', 'build',
RESOURCE_NOT_AVAILABLE, RESOURCE_NOT_AVAILABLE,
@ -3122,7 +3122,7 @@ class ModuleAutoGen(AutoGen):
for Depex in DepexList: for Depex in DepexList:
for key in Depex: for key in Depex:
DepexStr += '[Depex.%s.%s]\n' % key DepexStr += '[Depex.%s.%s]\n' % key
DepexStr += '\n'.join(['# '+ val for val in Depex[key]]) DepexStr += '\n'.join('# '+ val for val in Depex[key])
DepexStr += '\n\n' DepexStr += '\n\n'
if not DepexStr: if not DepexStr:
return '[Depex.%s]\n' % self.Arch return '[Depex.%s]\n' % self.Arch
@ -3136,7 +3136,7 @@ class ModuleAutoGen(AutoGen):
DepexStr += ' AND ' DepexStr += ' AND '
DepexStr += '(' DepexStr += '('
for D in Depex.values(): for D in Depex.values():
DepexStr += ' '.join([val for val in D]) DepexStr += ' '.join(val for val in D)
Index = DepexStr.find('END') Index = DepexStr.find('END')
if Index > -1 and Index == len(DepexStr) - 3: if Index > -1 and Index == len(DepexStr) - 3:
DepexStr = DepexStr[:-3] DepexStr = DepexStr[:-3]

View File

@ -80,7 +80,7 @@ class VariableMgr(object):
try: try:
newvaluestr = "{" + ",".join(VariableMgr.assemble_variable(newvalue)) +"}" newvaluestr = "{" + ",".join(VariableMgr.assemble_variable(newvalue)) +"}"
except: except:
EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join([item.pcdname for item in sku_var_info_offset_list]))) EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join(item.pcdname for item in sku_var_info_offset_list)))
n = sku_var_info_offset_list[0] n = sku_var_info_offset_list[0]
indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , DataType.TAB_VOID)] indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , DataType.TAB_VOID)]
self.VarInfo = [item[0] for item in indexedvarinfo.values()] self.VarInfo = [item[0] for item in indexedvarinfo.values()]
@ -116,9 +116,9 @@ class VariableMgr(object):
default_sku_default = indexedvarinfo[index].get((DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT)) default_sku_default = indexedvarinfo[index].get((DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT))
if default_sku_default.data_type not in DataType.TAB_PCD_NUMERIC_TYPES: if default_sku_default.data_type not in DataType.TAB_PCD_NUMERIC_TYPES:
var_max_len = max([len(var_item.default_value.split(",")) for var_item in sku_var_info.values()]) var_max_len = max(len(var_item.default_value.split(",")) for var_item in sku_var_info.values())
if len(default_sku_default.default_value.split(",")) < var_max_len: if len(default_sku_default.default_value.split(",")) < var_max_len:
tail = ",".join([ "0x00" for i in range(var_max_len-len(default_sku_default.default_value.split(",")))]) tail = ",".join("0x00" for i in range(var_max_len-len(default_sku_default.default_value.split(","))))
default_data_buffer = VariableMgr.PACK_VARIABLES_DATA(default_sku_default.default_value,default_sku_default.data_type,tail) default_data_buffer = VariableMgr.PACK_VARIABLES_DATA(default_sku_default.default_value,default_sku_default.data_type,tail)
@ -136,7 +136,7 @@ class VariableMgr(object):
if default_sku_default.data_type not in DataType.TAB_PCD_NUMERIC_TYPES: if default_sku_default.data_type not in DataType.TAB_PCD_NUMERIC_TYPES:
if len(other_sku_other.default_value.split(",")) < var_max_len: if len(other_sku_other.default_value.split(",")) < var_max_len:
tail = ",".join([ "0x00" for i in range(var_max_len-len(other_sku_other.default_value.split(",")))]) tail = ",".join("0x00" for i in range(var_max_len-len(other_sku_other.default_value.split(","))))
others_data_buffer = VariableMgr.PACK_VARIABLES_DATA(other_sku_other.default_value,other_sku_other.data_type,tail) others_data_buffer = VariableMgr.PACK_VARIABLES_DATA(other_sku_other.default_value,other_sku_other.data_type,tail)

View File

@ -833,7 +833,7 @@ class TemplateString(object):
def Append(self, AppendString, Dictionary=None): def Append(self, AppendString, Dictionary=None):
if Dictionary: if Dictionary:
SectionList = self._Parse(AppendString) SectionList = self._Parse(AppendString)
self.String += "".join([S.Instantiate(Dictionary) for S in SectionList]) self.String += "".join(S.Instantiate(Dictionary) for S in SectionList)
else: else:
self.String += AppendString self.String += AppendString
@ -844,7 +844,7 @@ class TemplateString(object):
# @retval str The string replaced with placeholder values # @retval str The string replaced with placeholder values
# #
def Replace(self, Dictionary=None): def Replace(self, Dictionary=None):
return "".join([S.Instantiate(Dictionary) for S in self._TemplateSectionList]) return "".join(S.Instantiate(Dictionary) for S in self._TemplateSectionList)
## Progress indicator class ## Progress indicator class
# #
@ -1926,7 +1926,7 @@ class DefaultStore():
if not self.DefaultStores or "0" in self.DefaultStores: if not self.DefaultStores or "0" in self.DefaultStores:
return "0",TAB_DEFAULT_STORES_DEFAULT return "0",TAB_DEFAULT_STORES_DEFAULT
else: else:
minvalue = min([int(value_str) for value_str in self.DefaultStores]) minvalue = min(int(value_str) for value_str in self.DefaultStores)
return (str(minvalue), self.DefaultStores[str(minvalue)]) return (str(minvalue), self.DefaultStores[str(minvalue)])
def GetMin(self,DefaultSIdList): def GetMin(self,DefaultSIdList):
if not DefaultSIdList: if not DefaultSIdList:
@ -2023,7 +2023,7 @@ class SkuClass():
skuorderset.append(self.GetSkuChain(skuname)) skuorderset.append(self.GetSkuChain(skuname))
skuorder = [] skuorder = []
for index in range(max([len(item) for item in skuorderset])): for index in range(max(len(item) for item in skuorderset)):
for subset in skuorderset: for subset in skuorderset:
if index > len(subset)-1: if index > len(subset)-1:
continue continue

View File

@ -818,27 +818,27 @@ def StringToArray(String):
if isinstance(String, unicode): if isinstance(String, unicode):
if len(unicode) == 0: if len(unicode) == 0:
return "{0x00,0x00}" return "{0x00,0x00}"
return "{%s,0x00,0x00}" % ",".join(["0x%02x,0x00" % ord(C) for C in String]) return "{%s,0x00,0x00}" % ",".join("0x%02x,0x00" % ord(C) for C in String)
elif String.startswith('L"'): elif String.startswith('L"'):
if String == "L\"\"": if String == "L\"\"":
return "{0x00,0x00}" return "{0x00,0x00}"
else: else:
return "{%s,0x00,0x00}" % ",".join(["0x%02x,0x00" % ord(C) for C in String[2:-1]]) return "{%s,0x00,0x00}" % ",".join("0x%02x,0x00" % ord(C) for C in String[2:-1])
elif String.startswith('"'): elif String.startswith('"'):
if String == "\"\"": if String == "\"\"":
return "{0x00,0x00}" return "{0x00,0x00}"
else: else:
StringLen = len(String[1:-1]) StringLen = len(String[1:-1])
if StringLen % 2: if StringLen % 2:
return "{%s,0x00}" % ",".join(["0x%02x" % ord(C) for C in String[1:-1]]) return "{%s,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1])
else: else:
return "{%s,0x00,0x00}" % ",".join(["0x%02x" % ord(C) for C in String[1:-1]]) return "{%s,0x00,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1])
elif String.startswith('{'): elif String.startswith('{'):
StringLen = len(String.split(",")) StringLen = len(String.split(","))
if StringLen % 2: if StringLen % 2:
return "{%s,0x00}" % ",".join([ C.strip() for C in String[1:-1].split(',')]) return "{%s,0x00}" % ",".join(C.strip() for C in String[1:-1].split(','))
else: else:
return "{%s}" % ",".join([ C.strip() for C in String[1:-1].split(',')]) return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(','))
else: else:
if len(String.split()) % 2: if len(String.split()) % 2:

View File

@ -1,7 +1,7 @@
## @file ## @file
# This file is used to create/update/query/erase table for files # This file is used to create/update/query/erase table for files
# #
# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -73,7 +73,7 @@ class Table(object):
self.ID = self.ID + self._ID_STEP_ self.ID = self.ID + self._ID_STEP_
if self.ID >= (self.IdBase + self._ID_MAX_): if self.ID >= (self.IdBase + self._ID_MAX_):
self.ID = self.IdBase + self._ID_STEP_ self.ID = self.IdBase + self._ID_STEP_
Values = ", ".join([str(Arg) for Arg in Args]) Values = ", ".join(str(Arg) for Arg in Args)
SqlCommand = "insert into %s values(%s, %s)" % (self.Table, self.ID, Values) SqlCommand = "insert into %s values(%s, %s)" % (self.Table, self.ID, Values)
EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand) EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand)
self.Cur.execute(SqlCommand) self.Cur.execute(SqlCommand)

View File

@ -761,7 +761,7 @@ class GenFds :
length = F.tell() length = F.tell()
F.seek(4) F.seek(4)
TmpStr = unpack('%dh' % ((length - 4) / 2), F.read()) TmpStr = unpack('%dh' % ((length - 4) / 2), F.read())
Name = ''.join([chr(c) for c in TmpStr[:-1]]) Name = ''.join(chr(c) for c in TmpStr[:-1])
else: else:
FileList = [] FileList = []
if 'fv.sec.txt' in MatchDict: if 'fv.sec.txt' in MatchDict:

View File

@ -1514,7 +1514,7 @@ class DscBuildData(PlatformBuildClassObject):
return len(Value) - 2 return len(Value) - 2
return len(Value) return len(Value)
return str(max([pcd_size for pcd_size in [get_length(item) for item in sku_values]])) return str(max(get_length(item) for item in sku_values))
@staticmethod @staticmethod
def ExecuteCommand (Command): def ExecuteCommand (Command):
@ -2078,7 +2078,7 @@ class DscBuildData(PlatformBuildClassObject):
SearchPathList = [] SearchPathList = []
SearchPathList.append(os.path.normpath(mws.join(GlobalData.gWorkspace, "BaseTools/Source/C/Include"))) SearchPathList.append(os.path.normpath(mws.join(GlobalData.gWorkspace, "BaseTools/Source/C/Include")))
SearchPathList.append(os.path.normpath(mws.join(GlobalData.gWorkspace, "BaseTools/Source/C/Common"))) SearchPathList.append(os.path.normpath(mws.join(GlobalData.gWorkspace, "BaseTools/Source/C/Common")))
SearchPathList.extend([str(item) for item in IncSearchList]) SearchPathList.extend(str(item) for item in IncSearchList)
IncFileList = GetDependencyList(IncludeFileFullPaths,SearchPathList) IncFileList = GetDependencyList(IncludeFileFullPaths,SearchPathList)
for include_file in IncFileList: for include_file in IncFileList:
MakeApp += "$(OBJECTS) : %s\n" % include_file MakeApp += "$(OBJECTS) : %s\n" % include_file
@ -2324,7 +2324,7 @@ class DscBuildData(PlatformBuildClassObject):
if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
for skuid in PcdObj.SkuInfoList: for skuid in PcdObj.SkuInfoList:
skuobj = PcdObj.SkuInfoList[skuid] skuobj = PcdObj.SkuInfoList[skuid]
mindefaultstorename = DefaultStoreObj.GetMin(set([defaultstorename for defaultstorename in skuobj.DefaultStoreDict])) mindefaultstorename = DefaultStoreObj.GetMin(set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict))
for defaultstorename in DefaultStores: for defaultstorename in DefaultStores:
if defaultstorename not in skuobj.DefaultStoreDict: if defaultstorename not in skuobj.DefaultStoreDict:
skuobj.DefaultStoreDict[defaultstorename] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename]) skuobj.DefaultStoreDict[defaultstorename] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])

View File

@ -698,7 +698,7 @@ class InfBuildData(ModuleBuildClassObject):
CName = Record[0] CName = Record[0]
Value = ProtocolValue(CName, self.Packages, self.MetaFile.Path) Value = ProtocolValue(CName, self.Packages, self.MetaFile.Path)
if Value is None: if Value is None:
PackageList = "\n\t".join([str(P) for P in self.Packages]) PackageList = "\n\t".join(str(P) for P in self.Packages)
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
"Value of Protocol [%s] is not found under [Protocols] section in" % CName, "Value of Protocol [%s] is not found under [Protocols] section in" % CName,
ExtraData=PackageList, File=self.MetaFile, Line=Record[-1]) ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
@ -723,7 +723,7 @@ class InfBuildData(ModuleBuildClassObject):
CName = Record[0] CName = Record[0]
Value = PpiValue(CName, self.Packages, self.MetaFile.Path) Value = PpiValue(CName, self.Packages, self.MetaFile.Path)
if Value is None: if Value is None:
PackageList = "\n\t".join([str(P) for P in self.Packages]) PackageList = "\n\t".join(str(P) for P in self.Packages)
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
"Value of PPI [%s] is not found under [Ppis] section in " % CName, "Value of PPI [%s] is not found under [Ppis] section in " % CName,
ExtraData=PackageList, File=self.MetaFile, Line=Record[-1]) ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
@ -748,7 +748,7 @@ class InfBuildData(ModuleBuildClassObject):
CName = Record[0] CName = Record[0]
Value = GuidValue(CName, self.Packages, self.MetaFile.Path) Value = GuidValue(CName, self.Packages, self.MetaFile.Path)
if Value is None: if Value is None:
PackageList = "\n\t".join([str(P) for P in self.Packages]) PackageList = "\n\t".join(str(P) for P in self.Packages)
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
"Value of Guid [%s] is not found under [Guids] section in" % CName, "Value of Guid [%s] is not found under [Guids] section in" % CName,
ExtraData=PackageList, File=self.MetaFile, Line=Record[-1]) ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
@ -918,7 +918,7 @@ class InfBuildData(ModuleBuildClassObject):
if Value is None: if Value is None:
Value = GuidValue(Token, self.Packages, self.MetaFile.Path) Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
if Value is None: if Value is None:
PackageList = "\n\t".join([str(P) for P in self.Packages]) PackageList = "\n\t".join(str(P) for P in self.Packages)
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
"Value of [%s] is not found in" % Token, "Value of [%s] is not found in" % Token,
ExtraData=PackageList, File=self.MetaFile, Line=Record[-1]) ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
@ -961,7 +961,7 @@ class InfBuildData(ModuleBuildClassObject):
if TokenSpaceGuid not in self.Guids: if TokenSpaceGuid not in self.Guids:
Value = GuidValue(TokenSpaceGuid, self.Packages, self.MetaFile.Path) Value = GuidValue(TokenSpaceGuid, self.Packages, self.MetaFile.Path)
if Value is None: if Value is None:
PackageList = "\n\t".join([str(P) for P in self.Packages]) PackageList = "\n\t".join(str(P) for P in self.Packages)
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
"Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid, "Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid,
ExtraData=PackageList, File=self.MetaFile, Line=LineNo) ExtraData=PackageList, File=self.MetaFile, Line=LineNo)
@ -1131,7 +1131,7 @@ class InfBuildData(ModuleBuildClassObject):
FORMAT_INVALID, FORMAT_INVALID,
"PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid, PcdRealName, self.MetaFile), "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid, PcdRealName, self.MetaFile),
File=self.MetaFile, Line=LineNo, File=self.MetaFile, Line=LineNo,
ExtraData="\t%s" % '\n\t'.join([str(P) for P in self.Packages]) ExtraData="\t%s" % '\n\t'.join(str(P) for P in self.Packages)
) )
Pcds[PcdCName, TokenSpaceGuid] = Pcd Pcds[PcdCName, TokenSpaceGuid] = Pcd

View File

@ -1,7 +1,7 @@
## @file ## @file
# This file is used to create/update/query/erase table for files # This file is used to create/update/query/erase table for files
# #
# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -73,7 +73,7 @@ class Table(object):
self.ID = self.ID + self._ID_STEP_ self.ID = self.ID + self._ID_STEP_
if self.ID >= (self.IdBase + self._ID_MAX_): if self.ID >= (self.IdBase + self._ID_MAX_):
self.ID = self.IdBase + self._ID_STEP_ self.ID = self.IdBase + self._ID_STEP_
Values = ", ".join([str(Arg) for Arg in Args]) Values = ", ".join(str(Arg) for Arg in Args)
SqlCommand = "insert into %s values(%s, %s)" % (self.Table, self.ID, Values) SqlCommand = "insert into %s values(%s, %s)" % (self.Table, self.ID, Values)
EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand) EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand)
self.Cur.execute(SqlCommand) self.Cur.execute(SqlCommand)

View File

@ -545,7 +545,7 @@ class BuildTask:
# while not BuildTask._ErrorFlag.isSet() and \ # while not BuildTask._ErrorFlag.isSet() and \
while len(BuildTask._RunningQueue) > 0: while len(BuildTask._RunningQueue) > 0:
EdkLogger.verbose("Waiting for thread ending...(%d)" % len(BuildTask._RunningQueue)) EdkLogger.verbose("Waiting for thread ending...(%d)" % len(BuildTask._RunningQueue))
EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join([Th.getName() for Th in threading.enumerate()])) EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join(Th.getName() for Th in threading.enumerate()))
# avoid tense loop # avoid tense loop
time.sleep(0.1) time.sleep(0.1)
except BaseException, X: except BaseException, X: