| Total Complexity | 3 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import graphinate |
||
| 2 | from pipdeptree._cli import get_options |
||
| 3 | from pipdeptree._discovery import get_installed_distributions |
||
| 4 | from pipdeptree._models import PackageDAG |
||
| 5 | from pipdeptree._non_host import handle_non_host_target |
||
| 6 | |||
| 7 | |||
| 8 | def dependency_graph_model(): |
||
| 9 | options = get_options(args=None) |
||
| 10 | handle_non_host_target(options) |
||
| 11 | |||
| 12 | pkgs = get_installed_distributions(local_only=options.local_only, user_only=options.user_only) |
||
| 13 | tree = PackageDAG.from_pkgs(pkgs) |
||
| 14 | |||
| 15 | graph_model = graphinate.model(name="Dependency Graph") |
||
| 16 | |||
| 17 | @graph_model.edge() |
||
| 18 | def dependency(): |
||
| 19 | for p, d in tree.items(): |
||
| 20 | for c in d: |
||
| 21 | yield {'source': p.project_name, 'target': c.project_name} |
||
| 22 | |||
| 23 | return graph_model |
||
| 24 | |||
| 25 | |||
| 26 | if __name__ == '__main__': |
||
| 27 | dependency_model = dependency_graph_model() |
||
| 28 | graphinate.materialize( |
||
| 29 | dependency_model, |
||
| 30 | builder=graphinate.builders.NetworkxBuilder, |
||
| 31 | actualizer=graphinate.plot |
||
| 32 | ) |
||
| 33 |