MCPcopy Create free account
hub / github.com/nodejs/node / EvalCondition

Function EvalCondition

tools/gyp/pylib/gyp/input.py:1112–1154  ·  view source on GitHub ↗

Returns the dict that should be used or None if the result was that nothing should be used.

(condition, conditions_key, phase, variables, build_file)

Source from the content-addressed store, hash-verified

1110
1111
1112def EvalCondition(condition, conditions_key, phase, variables, build_file):
1113 """Returns the dict that should be used or None if the result was
1114 that nothing should be used."""
1115 if not isinstance(condition, list):
1116 raise GypError(conditions_key + " must be a list")
1117 if len(condition) < 2:
1118 # It's possible that condition[0] won't work in which case this
1119 # attempt will raise its own IndexError. That's probably fine.
1120 raise GypError(
1121 conditions_key
1122 + " "
1123 + condition[0]
1124 + " must be at least length 2, not "
1125 + str(len(condition))
1126 )
1127
1128 i = 0
1129 result = None
1130 while i < len(condition):
1131 cond_expr = condition[i]
1132 true_dict = condition[i + 1]
1133 if not isinstance(true_dict, dict):
1134 raise GypError(
1135 f"{conditions_key} {cond_expr} must be followed by a dictionary, "
1136 f"not {type(true_dict)}"
1137 )
1138 if len(condition) > i + 2 and isinstance(condition[i + 2], dict):
1139 false_dict = condition[i + 2]
1140 i = i + 3
1141 if i != len(condition):
1142 raise GypError(
1143 f"{conditions_key} {cond_expr} has "
1144 f"{len(condition) - i} unexpected trailing items"
1145 )
1146 else:
1147 false_dict = None
1148 i = i + 2
1149 if result is None:
1150 result = EvalSingleCondition(
1151 cond_expr, true_dict, false_dict, phase, variables, build_file
1152 )
1153
1154 return result
1155
1156
1157def EvalSingleCondition(cond_expr, true_dict, false_dict, phase, variables, build_file):

Callers 1

ProcessConditionsInDictFunction · 0.85

Calls 4

GypErrorClass · 0.90
strFunction · 0.85
EvalSingleConditionFunction · 0.85
typeFunction · 0.50

Tested by

no test coverage detected