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
\r
## Simply optimize the dependency expression by removing duplicated operands\r
def Optimize(self):\r
- ValidOpcode = list(set(self.OpcodeList))\r
- if len(ValidOpcode) != 1 or ValidOpcode[0] not in [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR]:\r
+ OpcodeSet = set(self.OpcodeList)\r
+ # if there are isn't one in the set, return\r
+ if len(OpcodeSet) != 1:\r
+ return\r
+ Op = OpcodeSet.pop()\r
+ #if Op isn't either OR or AND, return\r
+ if Op not in [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR]:\r
return\r
- Op = ValidOpcode[0]\r
NewOperand = []\r
AllOperand = set()\r
for Token in self.PostfixNotation:\r
os.utime(Option.OutputFile, None)\r
else:\r
Dpx.Generate()\r
- except BaseException, X:\r
+ except BaseException as X:\r
EdkLogger.quiet("")\r
if Option is not None and Option.debug is not None:\r
EdkLogger.quiet(traceback.format_exc())\r