return 1\r
\r
try:\r
- while 1:\r
+ while True:\r
line = file.readline()\r
if not line:\r
break\r
StatusCmd = "svn st -v --depth infinity --non-interactive"\r
contents = ShellCommandResults(StatusCmd, opts)\r
os.chdir(Cwd)\r
- if type(contents) is ListType:\r
+ if isinstance(contents, ListType):\r
for line in contents:\r
if line.startswith("M "):\r
Modified = True\r
InfoCmd = "svn info %s" % SrcPath.replace("\\", "/").strip()\r
Revision = 0\r
contents = ShellCommandResults(InfoCmd, opts)\r
- if type(contents) is IntType:\r
+ if isinstance(contents, IntType):\r
return 0, Modified\r
for line in contents:\r
line = line.strip()\r
VerCmd = "svn --version"\r
contents = ShellCommandResults(VerCmd, opts)\r
opts.silent = OriginalSilent\r
- if type(contents) is IntType:\r
+ if isinstance(contents, IntType):\r
if opts.verbose:\r
sys.stdout.write("SVN does not appear to be available.\n")\r
sys.stdout.flush()\r
return hash(self.Target.Path)\r
\r
def __eq__(self, Other):\r
- if type(Other) == type(self):\r
+ if isinstance(Other, type(self)):\r
return Other.Target.Path == self.Target.Path\r
else:\r
return str(Other) == self.Target.Path\r
def __init__(self, Expression, ModuleType, Optimize=False):\r
self.ModuleType = ModuleType\r
self.Phase = gType2Phase[ModuleType]\r
- if type(Expression) == type([]):\r
+ if isinstance(Expression, type([])):\r
self.ExpressionString = " ".join(Expression)\r
self.TokenList = Expression\r
else:\r
WrnExp = None\r
\r
if Operator not in {"==", "!=", ">=", "<=", ">", "<", "in", "not in"} and \\r
- (type(Oprand1) == type('') or type(Oprand2) == type('')):\r
+ (isinstance(Oprand1, type('')) or isinstance(Oprand2, type(''))):\r
raise BadExpression(ERR_STRING_EXPR % Operator)\r
if Operator in {'in', 'not in'}:\r
- if type(Oprand1) != type(''):\r
+ if not isinstance(Oprand1, type('')):\r
Oprand1 = IntToStr(Oprand1)\r
- if type(Oprand2) != type(''):\r
+ if not isinstance(Oprand2, type('')):\r
Oprand2 = IntToStr(Oprand2)\r
TypeDict = {\r
type(0) : 0,\r
\r
EvalStr = ''\r
if Operator in {"!", "NOT", "not"}:\r
- if type(Oprand1) == type(''):\r
+ if isinstance(Oprand1, type('')):\r
raise BadExpression(ERR_STRING_EXPR % Operator)\r
EvalStr = 'not Oprand1'\r
elif Operator in {"~"}:\r
- if type(Oprand1) == type(''):\r
+ if isinstance(Oprand1, type('')):\r
raise BadExpression(ERR_STRING_EXPR % Operator)\r
EvalStr = '~ Oprand1'\r
else:\r
if Operator in {"+", "-"} and (type(True) in {type(Oprand1), type(Oprand2)}):\r
# Boolean in '+'/'-' will be evaluated but raise warning\r
WrnExp = WrnExpression(WRN_BOOL_EXPR)\r
- elif type('') in {type(Oprand1), type(Oprand2)} and type(Oprand1)!= type(Oprand2):\r
+ elif type('') in {type(Oprand1), type(Oprand2)} and not isinstance(Oprand1, type(Oprand2)):\r
# == between string and number/boolean will always return False, != return True\r
if Operator == "==":\r
WrnExp = WrnExpression(WRN_EQCMP_STR_OTHERS)\r
pass\r
else:\r
raise BadExpression(ERR_EXPR_TYPE)\r
- if type(Oprand1) == type('') and type(Oprand2) == type(''):\r
+ if isinstance(Oprand1, type('')) and isinstance(Oprand2, type('')):\r
if (Oprand1.startswith('L"') and not Oprand2.startswith('L"')) or \\r
(not Oprand1.startswith('L"') and Oprand2.startswith('L"')):\r
raise BadExpression(ERR_STRING_CMP % (Oprand1, Operator, Oprand2))\r
- if 'in' in Operator and type(Oprand2) == type(''):\r
+ if 'in' in Operator and isinstance(Oprand2, type('')):\r
Oprand2 = Oprand2.split()\r
EvalStr = 'Oprand1 ' + Operator + ' Oprand2'\r
\r
def __init__(self, Expression, SymbolTable={}):\r
super(ValueExpression, self).__init__(self, Expression, SymbolTable)\r
self._NoProcess = False\r
- if type(Expression) != type(''):\r
+ if not isinstance(Expression, type('')):\r
self._Expr = Expression\r
self._NoProcess = True\r
return\r
Token = self._GetToken()\r
except BadExpression:\r
pass\r
- if type(Token) == type('') and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len:\r
+ if isinstance(Token, type('')) and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len:\r
return self._Expr\r
\r
self._Idx = 0\r
\r
Val = self._ConExpr()\r
RealVal = Val\r
- if type(Val) == type(''):\r
+ if isinstance(Val, type('')):\r
if Val == 'L""':\r
Val = False\r
elif not Val:\r
Ex.Pcd = self._Token\r
raise Ex\r
self._Token = ValueExpression(self._Symb[self._Token], self._Symb)(True, self._Depth+1)\r
- if type(self._Token) != type(''):\r
+ if not isinstance(self._Token, type('')):\r
self._LiteralToken = hex(self._Token)\r
return\r
\r
if Ch == ')':\r
TmpValue = self._Expr[Idx :self._Idx - 1]\r
TmpValue = ValueExpression(TmpValue)(True)\r
- TmpValue = '0x%x' % int(TmpValue) if type(TmpValue) != type('') else TmpValue\r
+ TmpValue = '0x%x' % int(TmpValue) if not isinstance(TmpValue, type('')) else TmpValue\r
break\r
self._Token, Size = ParseFieldValue(Prefix + '(' + TmpValue + ')')\r
return self._Token\r
PcdValue = PcdValue.strip()\r
if PcdValue.startswith('{') and PcdValue.endswith('}'):\r
PcdValue = SplitPcdValueString(PcdValue[1:-1])\r
- if type(PcdValue) == type([]):\r
+ if isinstance(PcdValue, type([])):\r
TmpValue = 0\r
Size = 0\r
ValueType = ''\r
else:\r
ItemValue = ParseFieldValue(Item)[0]\r
\r
- if type(ItemValue) == type(''):\r
+ if isinstance(ItemValue, type('')):\r
ItemValue = int(ItemValue, 0)\r
\r
TmpValue = (ItemValue << (Size * 8)) | TmpValue\r
TmpValue, Size = ParseFieldValue(PcdValue)\r
except BadExpression as Value:\r
raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value))\r
- if type(TmpValue) == type(''):\r
+ if isinstance(TmpValue, type('')):\r
try:\r
TmpValue = int(TmpValue)\r
except:\r
TmpValue = ValueExpressionEx(Item, ValueType, self._Symb)(True)\r
else:\r
TmpValue = ValueExpressionEx(Item, self.PcdType, self._Symb)(True)\r
- Item = '0x%x' % TmpValue if type(TmpValue) != type('') else TmpValue\r
+ Item = '0x%x' % TmpValue if not isinstance(TmpValue, type('')) else TmpValue\r
if ItemSize == 0:\r
ItemValue, ItemSize = ParseFieldValue(Item)\r
if Item[0] not in {'"', 'L', '{'} and ItemSize > 1:\r
return '{' + out + '}', Size\r
\r
def ParseFieldValue (Value):\r
- if type(Value) == type(0):\r
+ if isinstance(Value, type(0)):\r
return Value, (Value.bit_length() + 7) / 8\r
- if type(Value) != type(''):\r
+ if not isinstance(Value, type('')):\r
raise BadExpression('Type %s is %s' %(Value, type(Value)))\r
Value = Value.strip()\r
if Value.startswith(TAB_UINT8) and Value.endswith(')'):\r
Printset.add(TAB_PRINTCHAR_BS)\r
Printset.add(TAB_PRINTCHAR_NUL)\r
if not set(Value).issubset(Printset):\r
- PrintList = list(Printset)\r
- PrintList.sort()\r
+ PrintList = sorted(Printset)\r
return False, "Invalid PCD string value of type [%s]; must be printable chars %s." % (Type, PrintList)\r
elif Type == 'BOOLEAN':\r
if Value not in ['TRUE', 'True', 'true', '0x1', '0x01', '1', 'FALSE', 'False', 'false', '0x0', '0x00', '0']:\r
# @retval True The two PathClass are the same\r
#\r
def __eq__(self, Other):\r
- if type(Other) == type(self):\r
+ if isinstance(Other, type(self)):\r
return self.Path == Other.Path\r
else:\r
return self.Path == str(Other)\r
# @retval -1 The first PathClass is less than the second PathClass\r
# @retval 1 The first PathClass is Bigger than the second PathClass\r
def __cmp__(self, Other):\r
- if type(Other) == type(self):\r
+ if isinstance(Other, type(self)):\r
OtherKey = Other.Path\r
else:\r
OtherKey = str(Other)\r
return ["DEFAULT"]\r
skulist = [sku]\r
nextsku = sku\r
- while 1:\r
+ while True:\r
nextsku = self.GetNextSkuId(nextsku)\r
skulist.append(nextsku)\r
if nextsku == "DEFAULT":\r
def __init__(self): \r
pass\r
def Calculate(self, Operand, DataType, SymbolTable): \r
- if type(Operand) == type('') and not Operand.isalnum():\r
+ if isinstance(Operand, type('')) and not Operand.isalnum():\r
Expr = "XOR ..."\r
raise BadExpression(ERR_SNYTAX % Expr)\r
rangeId = str(uuid.uuid1())\r
def __init__(self): \r
pass\r
def Calculate(self, Operand, DataType, SymbolTable): \r
- if type(Operand) == type('') and not Operand.isalnum():\r
+ if isinstance(Operand, type('')) and not Operand.isalnum():\r
Expr = "LE ..."\r
raise BadExpression(ERR_SNYTAX % Expr)\r
rangeId1 = str(uuid.uuid1())\r
def __init__(self): \r
pass\r
def Calculate(self, Operand, DataType, SymbolTable):\r
- if type(Operand) == type('') and not Operand.isalnum():\r
+ if isinstance(Operand, type('')) and not Operand.isalnum():\r
Expr = "LT ..." \r
raise BadExpression(ERR_SNYTAX % Expr) \r
rangeId1 = str(uuid.uuid1())\r
def __init__(self): \r
pass\r
def Calculate(self, Operand, DataType, SymbolTable): \r
- if type(Operand) == type('') and not Operand.isalnum():\r
+ if isinstance(Operand, type('')) and not Operand.isalnum():\r
Expr = "GE ..."\r
raise BadExpression(ERR_SNYTAX % Expr)\r
rangeId1 = str(uuid.uuid1())\r
def __init__(self): \r
pass\r
def Calculate(self, Operand, DataType, SymbolTable): \r
- if type(Operand) == type('') and not Operand.isalnum():\r
+ if isinstance(Operand, type('')) and not Operand.isalnum():\r
Expr = "GT ..."\r
raise BadExpression(ERR_SNYTAX % Expr)\r
rangeId1 = str(uuid.uuid1())\r
def __init__(self): \r
pass\r
def Calculate(self, Operand, DataType, SymbolTable): \r
- if type(Operand) == type('') and not Operand.isalnum():\r
+ if isinstance(Operand, type('')) and not Operand.isalnum():\r
Expr = "EQ ..."\r
raise BadExpression(ERR_SNYTAX % Expr)\r
rangeId1 = str(uuid.uuid1())\r
def __init__(self, Expression, PcdDataType, SymbolTable = {}):\r
super(RangeExpression, self).__init__(self, Expression, PcdDataType, SymbolTable)\r
self._NoProcess = False\r
- if type(Expression) != type(''):\r
+ if not isinstance(Expression, type('')):\r
self._Expr = Expression\r
self._NoProcess = True\r
return\r
Ex.Pcd = self._Token\r
raise Ex\r
self._Token = RangeExpression(self._Symb[self._Token], self._Symb)(True, self._Depth + 1)\r
- if type(self._Token) != type(''):\r
+ if not isinstance(self._Token, type('')):\r
self._LiteralToken = hex(self._Token)\r
return\r
\r
def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False):\r
NewList = []\r
for String in StringList:\r
- if type(String) == type(''):\r
+ if isinstance(String, type('')):\r
NewList.append(ReplaceMacro(String, MacroDefinitions, SelfReplacement))\r
else:\r
NewList.append(String)\r
# Get String of a List\r
#\r
def GetStringOfList(List, Split=' '):\r
- if type(List) != type([]):\r
+ if not isinstance(List, type([])):\r
return List\r
Str = ''\r
for Item in List:\r
if ErrorCode != 0:\r
EdkLogger.error("tools_def.txt parser", FILE_NOT_FOUND, ExtraData=IncFile)\r
\r
- if type(IncFileTmp) is PathClass:\r
+ if isinstance(IncFileTmp, PathClass):\r
IncFile = IncFileTmp.Path\r
else:\r
IncFile = IncFileTmp\r
"Invalid parameter FilePath: %s." % FilePath) \r
\r
Content = FILE_COMMENT_TEMPLATE\r
- Pcds = self._VpdArray.keys()\r
- Pcds.sort()\r
+ Pcds = sorted(self._VpdArray.keys())\r
for Pcd in Pcds:\r
i = 0\r
PcdTokenCName = Pcd.TokenCName\r
self._ItemType = MODEL_META_DATA_DEFINE\r
# DEFINE defined macros\r
if Type == TAB_DSC_DEFINES_DEFINE:\r
- if type(self) == DecParser:\r
+ if isinstance(self, DecParser):\r
if MODEL_META_DATA_HEADER in self._SectionType:\r
self._FileLocalMacros[Name] = Value\r
else:\r
SectionLocalMacros = self._SectionsMacroDict[SectionDictKey]\r
SectionLocalMacros[Name] = Value\r
# EDK_GLOBAL defined macros\r
- elif type(self) != DscParser:\r
+ elif not isinstance(self, DscParser):\r
EdkLogger.error('Parser', FORMAT_INVALID, "EDK_GLOBAL can only be used in .dsc file",\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1)\r
elif self._SectionType != MODEL_META_DATA_HEADER:\r
# DataInfo = [data_type, scope1(arch), scope2(platform/moduletype)]\r
#\r
def __getitem__(self, DataInfo):\r
- if type(DataInfo) != type(()):\r
+ if not isinstance(DataInfo, type(())):\r
DataInfo = (DataInfo,)\r
\r
# Parse the file first, if necessary\r
TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT)\r
self._ValueList[0:len(TokenList)] = TokenList\r
# Don't do macro replacement for dsc file at this point\r
- if type(self) != DscParser:\r
+ if not isinstance(self, DscParser):\r
Macros = self._Macros\r
self._ValueList = [ReplaceMacro(Value, Macros) for Value in self._ValueList]\r
\r
if os.path.exists(UniFile):\r
self._UniObj = UniParser(UniFile, IsExtraUni=False, IsModuleUni=False)\r
\r
- if type(self) == InfParser and self._Version < 0x00010005:\r
+ if isinstance(self, InfParser) and self._Version < 0x00010005:\r
# EDK module allows using defines as macros\r
self._FileLocalMacros[Name] = Value\r
self._Defines[Name] = Value\r
self._ValueList[1] = TokenList2[1] # keys\r
else:\r
self._ValueList[1] = TokenList[0]\r
- if len(TokenList) == 2 and type(self) != DscParser: # value\r
+ if len(TokenList) == 2 and not isinstance(self, DscParser): # value\r
self._ValueList[2] = ReplaceMacro(TokenList[1], self._Macros)\r
\r
if self._ValueList[1].count('_') != 4:\r
Element.appendChild(Doc.createTextNode(String))\r
\r
for Item in NodeList:\r
- if type(Item) == type([]):\r
+ if isinstance(Item, type([])):\r
Key = Item[0]\r
Value = Item[1]\r
if Key != '' and Key is not None and Value != '' and Value is not None:\r
# @return: The name of parameter\r
#\r
def GetParameterName(Parameter):\r
- if type(Parameter) == type('') and Parameter.startswith('&'):\r
+ if isinstance(Parameter, type('')) and Parameter.startswith('&'):\r
return Parameter[1:].replace('{', '').replace('}', '').replace('\r', '').replace('\n', '').strip()\r
else:\r
return Parameter.strip()\r
MacroDict.update(GlobalData.gCommandLineDefines)\r
if GlobalData.BuildOptionPcd:\r
for Item in GlobalData.BuildOptionPcd:\r
- if type(Item) is tuple:\r
+ if isinstance(Item, tuple):\r
continue\r
PcdName, TmpValue = Item.split("=")\r
TmpValue = BuildOptionValue(TmpValue, {})\r
if not Name:\r
continue\r
\r
- Name = ' '.join(Name) if type(Name) == type([]) else Name\r
+ Name = ' '.join(Name) if isinstance(Name, type([])) else Name\r
GuidXRefFile.write("%s %s\n" %(FileStatementGuid, Name))\r
\r
# Append GUIDs, Protocols, and PPIs to the Xref file\r
def Print(self):\r
errMsg = ''\r
for Key in self.TargetTxtDictionary:\r
- if type(self.TargetTxtDictionary[Key]) == type([]):\r
+ if isinstance(self.TargetTxtDictionary[Key], type([])):\r
print("%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key])))\r
elif self.TargetTxtDictionary[Key] is None:\r
errMsg += " Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep \r
if Pcd.GetSupModuleList():\r
Statement += GenDecTailComment(Pcd.GetSupModuleList())\r
\r
- ArchList = Pcd.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(Pcd.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if SortedArch in NewSectionDict:\r
NewSectionDict[SortedArch] = \\r
#\r
if Guid.GetSupModuleList():\r
Statement += GenDecTailComment(Guid.GetSupModuleList()) \r
- ArchList = Guid.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(Guid.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if SortedArch in NewSectionDict:\r
NewSectionDict[SortedArch] = \\r
#\r
if Protocol.GetSupModuleList():\r
Statement += GenDecTailComment(Protocol.GetSupModuleList())\r
- ArchList = Protocol.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(Protocol.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if SortedArch in NewSectionDict:\r
NewSectionDict[SortedArch] = \\r
#\r
if Ppi.GetSupModuleList():\r
Statement += GenDecTailComment(Ppi.GetSupModuleList())\r
- ArchList = Ppi.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(Ppi.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if SortedArch in NewSectionDict:\r
NewSectionDict[SortedArch] = \\r
if LibraryClass.GetSupModuleList():\r
Statement += \\r
GenDecTailComment(LibraryClass.GetSupModuleList())\r
- ArchList = LibraryClass.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(LibraryClass.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if SortedArch in NewSectionDict:\r
NewSectionDict[SortedArch] = \\r
Statement += RelaPath.replace('\\', '/')\r
if FFE:\r
Statement += '|' + FFE\r
- ArchList = PackageDependency.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(PackageDependency.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if SortedArch in NewSectionDict:\r
NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]\r
SourceFile = Source.GetSourceFile()\r
Family = Source.GetFamily()\r
FeatureFlag = Source.GetFeatureFlag()\r
- SupArchList = Source.GetSupArchList()\r
- SupArchList.sort()\r
+ SupArchList = sorted(Source.GetSupArchList())\r
SortedArch = ' '.join(SupArchList)\r
Statement = GenSourceStatement(ConvertPath(SourceFile), Family, FeatureFlag)\r
if SortedArch in NewSectionDict:\r
#\r
# merge duplicate items\r
#\r
- ArchList = Guid.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(Guid.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if (Statement, SortedArch) in GuidDict:\r
PreviousComment = GuidDict[Statement, SortedArch]\r
#\r
# merge duplicate items\r
#\r
- ArchList = Object.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(Object.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if (Statement, SortedArch) in Dict:\r
PreviousComment = Dict[Statement, SortedArch]\r
#\r
# Merge duplicate entries\r
#\r
- ArchList = Pcd.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(Pcd.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
if (Statement, SortedArch) in Dict:\r
PreviousComment = Dict[Statement, SortedArch]\r
if CommentStr and not CommentStr.endswith('\n#\n'):\r
CommentStr = CommentStr + '#\n'\r
NewStateMent = CommentStr + Statement\r
- SupArch = Obj.GetSupArchList()\r
- SupArch.sort()\r
+ SupArch = sorted(Obj.GetSupArchList())\r
SortedArch = ' '.join(SupArch)\r
if SortedArch in NewSectionDict:\r
NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [NewStateMent]\r
FileName = ConvertPath(FileNameObj.GetFilename())\r
FileType = FileNameObj.GetFileType()\r
FFE = FileNameObj.GetFeatureFlag()\r
- ArchList = FileNameObj.GetSupArchList()\r
- ArchList.sort()\r
+ ArchList = sorted(FileNameObj.GetSupArchList())\r
SortedArch = ' '.join(ArchList)\r
Key = (FileName, FileType, FFE, SortedArch)\r
if Key in BinariesDict:\r
# Check whether PathClass are the same\r
#\r
def __eq__(self, Other):\r
- if type(Other) == type(self):\r
+ if isinstance(Other, type(self)):\r
return self.Path == Other.Path\r
else:\r
return self.Path == str(Other)\r
if not ArchList:\r
return NewArchList\r
\r
- if type(ArchList) == list:\r
+ if isinstance(ArchList, list):\r
for Arch in ArchList:\r
Arch = Arch.upper()\r
NewArchList.append(Arch)\r
- elif type(ArchList) == str:\r
+ elif isinstance(ArchList, str):\r
ArchList = ArchList.upper()\r
NewArchList.append(ArchList)\r
\r
#\r
# Index may out of bound\r
#\r
- if type(List[Index]) != type(1) or \\r
+ if not isinstance(List[Index], type(1)) or \\r
len(Value) > List[Index] or len(Value) < 3:\r
return False\r
\r
# @param Split: split character\r
#\r
def GetStringOfList(List, Split=' '):\r
- if type(List) != type([]):\r
+ if not isinstance(List, type([])):\r
return List\r
Str = ''\r
for Item in List:\r
Element.appendChild(Doc.createTextNode(String))\r
\r
for Item in NodeList:\r
- if type(Item) == type([]):\r
+ if isinstance(Item, type([])):\r
Key = Item[0]\r
Value = Item[1]\r
if Key != '' and Key is not None and Value != '' and Value is not None:\r
# \r
PackagePath = os.path.split(self.GetFullPath())[0]\r
IncludePathList = \\r
- [os.path.normpath(Path) + sep for Path in IncludesDict.keys()]\r
- IncludePathList.sort()\r
+ sorted([os.path.normpath(Path) + sep for Path in IncludesDict.keys()])\r
\r
#\r
# get a non-overlap set of include path, IncludePathList should be \r
SourceFile = Item.GetSourceFileName()\r
Family = Item.GetFamily()\r
FeatureFlag = Item.GetFeatureFlagExp()\r
- SupArchList = ConvertArchList(Item.GetSupArchList())\r
- SupArchList.sort()\r
+ SupArchList = sorted(ConvertArchList(Item.GetSupArchList()))\r
Source = SourceFileObject()\r
Source.SetSourceFile(SourceFile)\r
Source.SetFamily(Family)\r
# can be used for the attribute.\r
# If both not have VALID_ARCHITECTURE comment and no architecturie specified, then keep it empty.\r
# \r
- SupArchList = ConvertArchList(ItemObj.GetSupArchList())\r
- SupArchList.sort()\r
+ SupArchList = sorted(ConvertArchList(ItemObj.GetSupArchList()))\r
if len(SupArchList) == 1 and SupArchList[0] == 'COMMON':\r
if not (len(OriSupArchList) == 1 or OriSupArchList[0] == 'COMMON'):\r
SupArchList = OriSupArchList\r
self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue\r
self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm\r
self.DefinitionPosition = PcdObject.DefinitionPosition if PcdObject.DefinitionPosition else self.DefinitionPosition\r
- if type(PcdObject) is StructurePcd:\r
+ if isinstance(PcdObject, StructurePcd):\r
self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile\r
self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs\r
self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues\r
for pcdname in Pcds:\r
pcd = Pcds[pcdname]\r
Pcds[pcdname].SkuInfoList = {TAB_DEFAULT:pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}\r
- if type(pcd) is StructurePcd and pcd.SkuOverrideValues:\r
+ if isinstance(pcd, StructurePcd) and pcd.SkuOverrideValues:\r
Pcds[pcdname].SkuOverrideValues = {TAB_DEFAULT:pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}\r
else:\r
for pcdname in Pcds:\r
pcd = Pcds[pcdname]\r
Pcds[pcdname].SkuInfoList = {skuid:pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}\r
- if type(pcd) is StructurePcd and pcd.SkuOverrideValues:\r
+ if isinstance(pcd, StructurePcd) and pcd.SkuOverrideValues:\r
Pcds[pcdname].SkuOverrideValues = {skuid:pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}\r
return Pcds\r
def CompleteHiiPcdsDefaultStores(self, Pcds):\r
def __ParsePcdFromCommandLine(self):\r
if GlobalData.BuildOptionPcd:\r
for i, pcd in enumerate(GlobalData.BuildOptionPcd):\r
- if type(pcd) is tuple:\r
+ if isinstance(pcd, tuple):\r
continue\r
(pcdname, pcdvalue) = pcd.split('=')\r
if not pcdvalue:\r
File=self.MetaFile, Line = StrPcdSet[str_pcd][0][5])\r
# Add the Structure PCD that only defined in DEC, don't have override in DSC file\r
for Pcd in self.DecPcds:\r
- if type (self._DecPcds[Pcd]) is StructurePcd:\r
+ if isinstance(self._DecPcds[Pcd], StructurePcd):\r
if Pcd not in S_pcd_set:\r
str_pcd_obj_str = StructurePcd()\r
str_pcd_obj_str.copy(self._DecPcds[Pcd])\r
#\r
# First judge whether this DEFINE is in conditional directive statements or not.\r
#\r
- if type(self) == DscParser and self._InDirective > -1:\r
+ if isinstance(self, DscParser) and self._InDirective > -1:\r
pass\r
else:\r
- if type(self) == DecParser:\r
+ if isinstance(self, DecParser):\r
if MODEL_META_DATA_HEADER in self._SectionType:\r
self._FileLocalMacros[Name] = Value\r
else:\r
self._ConstructSectionMacroDict(Name, Value)\r
\r
# EDK_GLOBAL defined macros\r
- elif type(self) != DscParser:\r
+ elif not isinstance(self, DscParser):\r
EdkLogger.error('Parser', FORMAT_INVALID, "EDK_GLOBAL can only be used in .dsc file",\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
elif self._SectionType != MODEL_META_DATA_HEADER:\r
# DataInfo = [data_type, scope1(arch), scope2(platform/moduletype)]\r
#\r
def __getitem__(self, DataInfo):\r
- if type(DataInfo) != type(()):\r
+ if not isinstance(DataInfo, type(())):\r
DataInfo = (DataInfo,)\r
\r
# Parse the file first, if necessary\r
TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT)\r
self._ValueList[0:len(TokenList)] = TokenList\r
# Don't do macro replacement for dsc file at this point\r
- if type(self) != DscParser:\r
+ if not isinstance(self, DscParser):\r
Macros = self._Macros\r
self._ValueList = [ReplaceMacro(Value, Macros) for Value in self._ValueList]\r
\r
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
\r
- if type(self) == InfParser and self._Version < 0x00010005:\r
+ if isinstance(self, InfParser) and self._Version < 0x00010005:\r
# EDK module allows using defines as macros\r
self._FileLocalMacros[Name] = Value\r
self._Defines[Name] = Value\r
self._ValueList[1] = TokenList2[1] # keys\r
else:\r
self._ValueList[1] = TokenList[0]\r
- if len(TokenList) == 2 and type(self) != DscParser: # value\r
+ if len(TokenList) == 2 and not isinstance(self, DscParser): # value\r
self._ValueList[2] = ReplaceMacro(TokenList[1], self._Macros)\r
\r
if self._ValueList[1].count('_') != 4:\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
+ if isinstance(self, DecParser):\r
SectionDictKey = self._SectionType[0], ScopeKey\r
else:\r
SectionDictKey = self._SectionType, ScopeKey\r
SpeSpeMacroDict = {}\r
\r
ActiveSectionType = self._SectionType\r
- if type(self) == DecParser:\r
+ if isinstance(self, DecParser):\r
ActiveSectionType = self._SectionType[0]\r
\r
for (SectionType, Scope) in self._SectionsMacroDict:\r
Macros.update(self._Symbols)\r
if GlobalData.BuildOptionPcd:\r
for Item in GlobalData.BuildOptionPcd:\r
- if type(Item) is tuple:\r
+ if isinstance(Item, tuple):\r
continue\r
PcdName, TmpValue = Item.split("=")\r
TmpValue = BuildOptionValue(TmpValue, self._GuidDict)\r
for Match in gOffsetGuidPattern.finditer(FvReport):\r
Guid = Match.group(2).upper()\r
OffsetInfo[Match.group(1)] = self._GuidsDb.get(Guid, Guid)\r
- OffsetList = OffsetInfo.keys()\r
- OffsetList.sort()\r
+ OffsetList = sorted(OffsetInfo.keys())\r
for Offset in OffsetList:\r
FileWrite (File, "%s %s" % (Offset, OffsetInfo[Offset]))\r
except IOError:\r
if EndOfProcedure is not None:\r
EndOfProcedure.set()\r
if Proc is None:\r
- if type(Command) != type(""):\r
+ if not isinstance(Command, type("")):\r
Command = " ".join(Command)\r
EdkLogger.error("build", COMMAND_FAILURE, "Failed to start command", ExtraData="%s [%s]" % (Command, WorkingDir))\r
\r
\r
# check the return code of the program\r
if Proc.returncode != 0:\r
- if type(Command) != type(""):\r
+ if not isinstance(Command, type("")):\r
Command = " ".join(Command)\r
# print out the Response file and its content when make failure\r
RespFile = os.path.join(WorkingDir, 'OUTPUT', 'respfilelist.txt')\r
replaceables = ('extract-dir', 'filename', 'url')
for replaceItem in fdata:
if replaceItem in replaceables: continue
- if type(fdata[replaceItem]) != str: continue
+ if not isinstance(fdata[replaceItem], str): continue\r
for replaceable in replaceables:
- if type(fdata[replaceable]) != str: continue
+ if not isinstance(fdata[replaceable], str): continue\r
if replaceable in fdata:
fdata[replaceable] = \
fdata[replaceable].replace(