Return all leaf nodes - that is, nodes with no dependents in their app. These are the "most current" version of an app's schema. Having more than one per app is technically an error, but one that gets handled further up, in the interactive command - it's usually the
(self, app=None)
| 253 | return sorted(roots) |
| 254 | |
| 255 | def leaf_nodes(self, app=None): |
| 256 | """ |
| 257 | Return all leaf nodes - that is, nodes with no dependents in their app. |
| 258 | These are the "most current" version of an app's schema. |
| 259 | Having more than one per app is technically an error, but one that |
| 260 | gets handled further up, in the interactive command - it's usually the |
| 261 | result of a VCS merge and needs some user input. |
| 262 | """ |
| 263 | leaves = set() |
| 264 | for node in self.nodes: |
| 265 | if all(key[0] != node[0] for key in self.node_map[node].children) and ( |
| 266 | not app or app == node[0] |
| 267 | ): |
| 268 | leaves.add(node) |
| 269 | return sorted(leaves) |
| 270 | |
| 271 | def ensure_not_cyclic(self): |
| 272 | # Algo from GvR: |