Skip to content

plugins

dependenpy plugins module.

InternalDependencies ¤

Bases: archan.Provider

Dependenpy provider for Archan.

Source code in dependenpy/plugins.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class InternalDependencies(archan.Provider):  # type: ignore  # noqa: WPS440
    """Dependenpy provider for Archan."""

    identifier = "dependenpy.InternalDependencies"
    name = "Internal Dependencies"
    description = "Provide matrix data about internal dependencies in a set of packages."
    argument_list = (
        archan.Argument("packages", list, "The list of packages to check for."),
        archan.Argument(
            "enforce_init",
            bool,
            default=True,
            description="Whether to assert presence of __init__.py files in directories.",
        ),
        archan.Argument("depth", int, "The depth of the matrix to generate."),
    )

    def get_data(self, packages: list[str], enforce_init: bool = True, depth: int = None) -> archan.DSM:
        """
        Provide matrix data for internal dependencies in a set of packages.

        Args:
            packages: the list of packages to check for.
            enforce_init: whether to assert presence of __init__.py files in directories.
            depth: the depth of the matrix to generate.

        Returns:
            Instance of archan DSM.
        """
        dsm = DependenpyDSM(*packages, enforce_init=enforce_init)
        if depth is None:
            depth = guess_depth(packages)
        matrix = dsm.as_matrix(depth=depth)
        return archan.DesignStructureMatrix(data=matrix.data, entities=matrix.keys)

get_data(packages, enforce_init=True, depth=None) ¤

Provide matrix data for internal dependencies in a set of packages.

Parameters:

Name Type Description Default
packages list[str]

the list of packages to check for.

required
enforce_init bool

whether to assert presence of init.py files in directories.

True
depth int

the depth of the matrix to generate.

None

Returns:

Type Description
archan.DSM

Instance of archan DSM.

Source code in dependenpy/plugins.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def get_data(self, packages: list[str], enforce_init: bool = True, depth: int = None) -> archan.DSM:
    """
    Provide matrix data for internal dependencies in a set of packages.

    Args:
        packages: the list of packages to check for.
        enforce_init: whether to assert presence of __init__.py files in directories.
        depth: the depth of the matrix to generate.

    Returns:
        Instance of archan DSM.
    """
    dsm = DependenpyDSM(*packages, enforce_init=enforce_init)
    if depth is None:
        depth = guess_depth(packages)
    matrix = dsm.as_matrix(depth=depth)
    return archan.DesignStructureMatrix(data=matrix.data, entities=matrix.keys)