(variables, the_dict, the_dict_key)
| 1254 | |
| 1255 | |
| 1256 | def LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key): |
| 1257 | # Any keys in the_dict's "variables" dict, if it has one, becomes a |
| 1258 | # variable. The variable name is the key name in the "variables" dict. |
| 1259 | # Variables that end with the % character are set only if they are unset in |
| 1260 | # the variables dict. the_dict_key is the name of the key that accesses |
| 1261 | # the_dict in the_dict's parent dict. If the_dict's parent is not a dict |
| 1262 | # (it could be a list or it could be parentless because it is a root dict), |
| 1263 | # the_dict_key will be None. |
| 1264 | for key, value in the_dict.get("variables", {}).items(): |
| 1265 | if type(value) not in (str, int, list): |
| 1266 | continue |
| 1267 | |
| 1268 | if key.endswith("%"): |
| 1269 | variable_name = key[:-1] |
| 1270 | if variable_name in variables: |
| 1271 | # If the variable is already set, don't set it. |
| 1272 | continue |
| 1273 | if the_dict_key == "variables" and variable_name in the_dict: |
| 1274 | # If the variable is set without a % in the_dict, and the_dict is a |
| 1275 | # variables dict (making |variables| a variables sub-dict of a |
| 1276 | # variables dict), use the_dict's definition. |
| 1277 | value = the_dict[variable_name] |
| 1278 | else: |
| 1279 | variable_name = key |
| 1280 | |
| 1281 | variables[variable_name] = value |
| 1282 | |
| 1283 | |
| 1284 | def ProcessVariablesAndConditionsInDict( |
no test coverage detected
searching dependent graphs…