def ParseConditionalStatementMacros(Line, Macros): if Line.upper().find('DEFINED(') > -1 or Line.upper().find('EXIST') > -1: return False Line = ReplaceMacro(Line, EotGlobalData.gMACRO, True) Line = ReplaceMacro(Line, Macros, True) Line = Line.replace("&&", "and") Line = Line.replace("||", "or") return eval(Line)
def AddToSelfMacro(SelfMacro, Line): Name, Value = '', '' List = GetSplitValueList(Line, TAB_EQUAL_SPLIT, 1) if len(List) == 2: Name = List[0] Value = List[1] Value = ReplaceMacro(Value, EotGlobalData.gMACRO, True) Value = ReplaceMacro(Value, SelfMacro, True) SelfMacro[Name] = Value return (Name, Value)
def ParseConditionalStatement(Line, Macros, StatusSet): NewLine = Line.upper() if NewLine.find(TAB_IF_EXIST.upper()) > -1: IfLine = Line[NewLine.find(TAB_IF_EXIST) + len(TAB_IF_EXIST) + 1:].strip() IfLine = ReplaceMacro(IfLine, EotGlobalData.gMACRO, True) IfLine = ReplaceMacro(IfLine, Macros, True) IfLine = IfLine.replace("\"", '') IfLine = IfLine.replace("(", '') IfLine = IfLine.replace(")", '') Status = os.path.exists(os.path.normpath(IfLine)) StatusSet.append([Status]) return True if NewLine.find(TAB_IF_DEF.upper()) > -1: IfLine = Line[NewLine.find(TAB_IF_DEF) + len(TAB_IF_DEF) + 1:].strip() Status = False if IfLine in Macros or IfLine in EotGlobalData.gMACRO: Status = True StatusSet.append([Status]) return True if NewLine.find(TAB_IF_N_DEF.upper()) > -1: IfLine = Line[NewLine.find(TAB_IF_N_DEF) + len(TAB_IF_N_DEF) + 1:].strip() Status = False if IfLine not in Macros and IfLine not in EotGlobalData.gMACRO: Status = True StatusSet.append([Status]) return True if NewLine.find(TAB_IF.upper()) > -1: IfLine = Line[NewLine.find(TAB_IF) + len(TAB_IF) + 1:].strip() Status = ParseConditionalStatementMacros(IfLine, Macros) StatusSet.append([Status]) return True if NewLine.find(TAB_ELSE_IF.upper()) > -1: IfLine = Line[NewLine.find(TAB_ELSE_IF) + len(TAB_ELSE_IF) + 1:].strip() Status = ParseConditionalStatementMacros(IfLine, Macros) StatusSet[-1].append(Status) return True if NewLine.find(TAB_ELSE.upper()) > -1: Status = False for Item in StatusSet[-1]: Status = Status or Item StatusSet[-1].append(not Status) return True if NewLine.find(TAB_END_IF.upper()) > -1: StatusSet.pop() return True return False
def AddToGlobalMacro(Name, Value): Value = ReplaceMacro(Value, EotGlobalData.gMACRO, True) EotGlobalData.gMACRO[Name] = Value