(fstruct, fs_class, visited)
| 1305 | |
| 1306 | |
| 1307 | def _remove_variables(fstruct, fs_class, visited): |
| 1308 | if id(fstruct) in visited: |
| 1309 | return |
| 1310 | visited.add(id(fstruct)) |
| 1311 | |
| 1312 | if _is_mapping(fstruct): |
| 1313 | items = list(fstruct.items()) |
| 1314 | elif _is_sequence(fstruct): |
| 1315 | items = list(enumerate(fstruct)) |
| 1316 | else: |
| 1317 | raise ValueError("Expected mapping or sequence") |
| 1318 | |
| 1319 | for fname, fval in items: |
| 1320 | if isinstance(fval, Variable): |
| 1321 | del fstruct[fname] |
| 1322 | elif isinstance(fval, fs_class): |
| 1323 | _remove_variables(fval, fs_class, visited) |
| 1324 | return fstruct |
| 1325 | |
| 1326 | |
| 1327 | ###################################################################### |
no test coverage detected
searching dependent graphs…