Passed
Push — main ( b6dbde...b789fa )
by Eran
01:16
created

python_dependencies   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A dependency_graph_model() 0 16 3
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