dependenpy ¤
Dependenpy package.
Show the inter-dependencies between modules of Python packages.
With dependenpy you will be able to analyze the internal dependencies in your Python code, i.e. which module needs which other module. You will then be able to build a dependency matrix and use it for other purposes.
If you read this message, you probably want to learn about the library and not the command-line tool: please refer to the README.md included in this package to get the link to the official documentation.
Modules:
-
cli–Deprecated. Import from
dependenpydirectly. -
debug–Deprecated. Import from
dependenpydirectly. -
dsm–Deprecated. Import from
dependenpydirectly. -
finder–Deprecated. Import from
dependenpydirectly. -
helpers–Deprecated. Import from
dependenpydirectly. -
node–Deprecated. Import from
dependenpydirectly. -
plugins–Deprecated. Import from
dependenpydirectly. -
structures–Deprecated. Import from
dependenpydirectly.
Classes:
-
DSM–DSM-capable class.
-
Dependency–Dependency class.
-
Edge–Edge class. Used in Graph class.
-
Finder–Main package finder class.
-
Graph–Graph class.
-
InstalledPackageFinder–Finder to find installed Python packages using importlib.
-
InternalDependencies–Dependenpy provider for Archan.
-
LeafNode–Shared code between Package and Module.
-
LocalPackageFinder–Finder to find local packages (directories on the disk).
-
Matrix–Matrix class.
-
Module–Module class.
-
NodeMixin–Shared code between DSM, Package and Module.
-
Package–Package class.
-
PackageFinder–Abstract package finder class.
-
PackageSpec–Holder for a package specification (given as argument to DSM).
-
PrintMixin–Print mixin class.
-
RootNode–Shared code between DSM and Package.
-
TreeMap–TreeMap class.
-
Vertex–Vertex class. Used in Graph class.
Functions:
-
get_parser–Return the CLI argument parser.
-
guess_depth–Guess the optimal depth to use for the given list of arguments.
-
main–Run the main program.
Attributes:
TEXT module-attribute ¤
TEXT = 'text'
DSM ¤
DSM(
*packages: str,
build_tree: bool = True,
build_dependencies: bool = True,
enforce_init: bool = True,
)
Bases: RootNode, NodeMixin, PrintMixin
DSM-capable class.
Technically speaking, a DSM instance is not a real DSM but more a tree representing the Python packages structure. However, it has the necessary methods to build a real DSM in the form of a square matrix, a dictionary or a tree-map.
Parameters:
-
*packages(str, default:()) –List of packages to search for.
-
build_tree(bool, default:True) –Auto-build the tree or not.
-
build_dependencies(bool, default:True) –Auto-build the dependencies or not.
-
enforce_init(bool, default:True) –If True, only treat directories if they contain an
__init__.pyfile.
Methods:
-
__bool__–Node as Boolean.
-
__contains__–Get result of _contains, cache it and return it.
-
__getitem__–Return the corresponding Package or Module object.
-
as_dict–Return the dependencies as a dictionary.
-
as_graph–Create a graph with self as node, cache it, return it.
-
as_matrix–Create a matrix with self as node, cache it, return it.
-
as_treemap–Return the dependencies as a TreeMap.
-
build_dependencies–Recursively build the dependencies for sub-modules and sub-packages.
-
build_tree–Build the Python packages tree.
-
get–Get item through
__getitem__and cache the result. -
get_target–Get the result of _get_target, cache it and return it.
-
print–Print the object in a file or on standard output by default.
-
print_graph–Print the graph for self's nodes.
-
print_matrix–Print the matrix for self's nodes.
-
print_treemap–Print the matrix for self's nodes.
Attributes:
-
base_packages(tuple[str, ...]) –Packages initially specified.
-
empty(bool) –Whether the node has neither modules nor packages.
-
enforce_init(bool) –Whether to enforce the presence of
__init__.pyfiles. -
finder(Finder) –Finder instance for locating packages and modules.
-
isdsm(bool) –Inherited from NodeMixin. Always True.
-
ismodule(bool) –Property to check if object is instance of Module.
-
ispackage(bool) –Property to check if object is instance of Package.
-
modules(list[Module]) –List of modules contained in the node.
-
not_found(list[str]) –List of packages that were not found.
-
packages(list[Package]) –List of packages contained in the node.
-
specs(list[PackageSpec]) –List of package specifications found.
-
submodules(list[Module]) –Property to return all sub-modules of the node, recursively.
Source code in src/dependenpy/_internal/dsm.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
base_packages instance-attribute ¤
Packages initially specified.
enforce_init instance-attribute ¤
enforce_init: bool = enforce_init
Whether to enforce the presence of __init__.py files.
finder instance-attribute ¤
Finder instance for locating packages and modules.
ispackage property ¤
ispackage: bool
Property to check if object is instance of Package.
Returns:
-
bool–Whether this object is a package.
specs instance-attribute ¤
specs: list[PackageSpec] = combine(specs)
List of package specifications found.
submodules property ¤
__bool__ ¤
__bool__() -> bool
Node as Boolean.
Returns:
-
bool–Result of node.empty.
Source code in src/dependenpy/_internal/node.py
106 107 108 109 110 111 112 | |
__contains__ ¤
Get result of _contains, cache it and return it.
Parameters:
Returns:
-
bool–True if self contains item, False otherwise.
Source code in src/dependenpy/_internal/node.py
67 68 69 70 71 72 73 74 75 76 77 78 | |
__getitem__ ¤
Return the corresponding Package or Module object.
Parameters:
-
item(str) –Name of the package/module, dot-separated.
Raises:
-
KeyError–When the package or module cannot be found.
Returns:
Source code in src/dependenpy/_internal/node.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
as_dict ¤
as_dict() -> dict
Return the dependencies as a dictionary.
Returns:
-
dict–Dictionary of dependencies.
Source code in src/dependenpy/_internal/node.py
300 301 302 303 304 305 306 307 308 309 310 | |
as_graph ¤
Create a graph with self as node, cache it, return it.
Parameters:
-
depth(int, default:0) –Depth of the graph.
Returns:
-
Graph–An instance of Graph.
Source code in src/dependenpy/_internal/node.py
312 313 314 315 316 317 318 319 320 321 322 323 | |
as_matrix ¤
Create a matrix with self as node, cache it, return it.
Parameters:
-
depth(int, default:0) –Depth of the matrix.
Returns:
-
Matrix–An instance of Matrix.
Source code in src/dependenpy/_internal/node.py
325 326 327 328 329 330 331 332 333 334 335 336 | |
as_treemap ¤
as_treemap() -> TreeMap
Return the dependencies as a TreeMap.
Returns:
-
TreeMap–An instance of TreeMap.
Source code in src/dependenpy/_internal/node.py
338 339 340 341 342 343 344 345 346 | |
build_dependencies ¤
build_dependencies() -> None
Recursively build the dependencies for sub-modules and sub-packages.
Iterate on node's modules then packages and call their build_dependencies methods.
Source code in src/dependenpy/_internal/node.py
217 218 219 220 221 222 223 224 225 226 | |
build_tree ¤
build_tree() -> None
Build the Python packages tree.
Source code in src/dependenpy/_internal/dsm.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
get ¤
Get item through __getitem__ and cache the result.
Parameters:
-
item(str) –Name of package or module.
Returns:
Source code in src/dependenpy/_internal/node.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
get_target ¤
Get the result of _get_target, cache it and return it.
Parameters:
-
target(str) –Target to find.
Returns:
Source code in src/dependenpy/_internal/node.py
173 174 175 176 177 178 179 180 181 182 183 184 | |
print ¤
Print the object in a file or on standard output by default.
Parameters:
-
format(str | None, default:TEXT) –Output format (csv, json or text).
-
output(IO, default:stdout) –Descriptor to an opened file (default to standard output).
-
**kwargs(Any, default:{}) –Additional arguments.
Source code in src/dependenpy/_internal/helpers.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
print_graph ¤
print_graph(
format: str | None = None,
output: IO = stdout,
depth: int = 0,
**kwargs: Any,
) -> None
Print the graph for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
depth(int, default:0) –Depth of the graph.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
graph.print.
Source code in src/dependenpy/_internal/node.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
print_matrix ¤
print_matrix(
format: str | None = None,
output: IO = stdout,
depth: int = 0,
**kwargs: Any,
) -> None
Print the matrix for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
depth(int, default:0) –Depth of the matrix.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
matrix.print.
Source code in src/dependenpy/_internal/node.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
print_treemap ¤
Print the matrix for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
treemap.print.
Source code in src/dependenpy/_internal/node.py
264 265 266 267 268 269 270 271 272 273 | |
Dependency ¤
Dependency class.
Represent a dependency from a module to another.
Parameters:
-
source(Module) –Source Module.
-
lineno(int) –Number of line at which import statement occurs.
-
target(str | Module | Package) –The target node.
-
what(str | None, default:None) –What is imported (optional).
Attributes:
-
external(bool) –Property to tell if the dependency's target is a valid node.
-
lineno–Line number of the import statement.
-
source–Source module.
-
target–Target module or package.
-
what–What is imported (optional).
Source code in src/dependenpy/_internal/dsm.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
Edge ¤
Edge class. Used in Graph class.
Parameters:
-
vertex_out(Vertex) –source vertex (edge going out).
-
vertex_in(Vertex) –target vertex (edge going in).
-
weight(int, default:1) –weight of the edge.
Methods:
Attributes:
-
vertex_in(Vertex | None) –Incoming vertex.
-
vertex_out(Vertex | None) –Outgoing vertex.
-
weight–Weight of the edge.
Source code in src/dependenpy/_internal/structures.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
go_from ¤
go_from(vertex: Vertex) -> None
Tell the edge to go out from this vertex.
Parameters:
-
vertex(Vertex) –vertex to go from.
Source code in src/dependenpy/_internal/structures.py
273 274 275 276 277 278 279 280 281 282 | |
go_in ¤
go_in(vertex: Vertex) -> None
Tell the edge to go into this vertex.
Parameters:
-
vertex(Vertex) –vertex to go into.
Source code in src/dependenpy/_internal/structures.py
284 285 286 287 288 289 290 291 292 293 | |
Finder ¤
Main package finder class.
Initialize it with a list of package finder classes (not instances).
Parameters:
-
finders(list[type] | None, default:None) –list of package finder classes (not instances) in a specific order. Default: [LocalPackageFinder, InstalledPackageFinder].
Methods:
-
find–Find a package using package finders.
Attributes:
-
finders(list[PackageFinder]) –Selected finders.
Source code in src/dependenpy/_internal/finder.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
find ¤
find(package: str, **kwargs: Any) -> PackageSpec | None
Find a package using package finders.
Return the first package found.
Parameters:
-
package(str) –package to find.
-
**kwargs(Any, default:{}) –additional keyword arguments used by finders.
Returns:
-
PackageSpec | None–Package spec or None.
Source code in src/dependenpy/_internal/finder.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
Graph ¤
Bases: PrintMixin
Graph class.
A class to build a graph given a list of nodes. After instantiation, it has two attributes: vertices, the set of nodes, and edges, the set of edges.
An intermediary matrix is built to ease the creation of the graph.
Parameters:
-
*nodes(list of DSM/Package/Module, default:()) –the nodes on which to build the graph.
-
depth(int, default:0) –the depth of the intermediary matrix. See the documentation for Matrix class.
Methods:
-
print–Print the object in a file or on standard output by default.
Attributes:
Source code in src/dependenpy/_internal/structures.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
print ¤
Print the object in a file or on standard output by default.
Parameters:
-
format(str | None, default:TEXT) –Output format (csv, json or text).
-
output(IO, default:stdout) –Descriptor to an opened file (default to standard output).
-
**kwargs(Any, default:{}) –Additional arguments.
Source code in src/dependenpy/_internal/helpers.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
InstalledPackageFinder ¤
Bases: PackageFinder
Finder to find installed Python packages using importlib.
Methods:
-
find–Find method.
find ¤
find(package: str, **kwargs: Any) -> PackageSpec | None
Find method.
Parameters:
Returns:
-
PackageSpec | None–Package spec or None.
Source code in src/dependenpy/_internal/finder.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
InternalDependencies ¤
Bases: Provider
Dependenpy provider for Archan.
Methods:
-
get_data–Provide matrix data for internal dependencies in a set of packages.
Attributes:
-
argument_list–List of arguments for the provider.
-
description–Description of the provider.
-
identifier–Identifier of the provider.
-
name–Name of the provider.
argument_list class-attribute instance-attribute ¤
argument_list = (
Argument(
"packages",
list,
"The list of packages to check for.",
),
Argument(
"enforce_init",
bool,
default=True,
description="Whether to assert presence of __init__.py files in directories.",
),
Argument(
"depth", int, "The depth of the matrix to generate."
),
)
List of arguments for the provider.
description class-attribute instance-attribute ¤
description = "Provide matrix data about internal dependencies in a set of packages."
Description of the provider.
identifier class-attribute instance-attribute ¤
identifier = 'dependenpy.InternalDependencies'
Identifier of the provider.
get_data ¤
Provide matrix data for internal dependencies in a set of packages.
Parameters:
-
packages(list[str]) –The list of packages to check for.
-
enforce_init(bool, default:True) –Whether to assert presence of init.py files in directories.
-
depth(int | None, default:None) –The depth of the matrix to generate.
Returns:
-
DSM–Instance of archan DSM.
Source code in src/dependenpy/_internal/plugins.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
LeafNode ¤
LeafNode()
Shared code between Package and Module.
Methods:
-
absolute_name–Return the absolute name of the node.
Attributes:
-
depth(int) –Property to tell the depth of the node in the tree.
-
root(Package) –Property to return the root of this node.
Source code in src/dependenpy/_internal/node.py
352 353 354 | |
absolute_name ¤
Return the absolute name of the node.
Concatenate names from root to self within depth.
Parameters:
-
depth(int, default:0) –Maximum depth to go to.
Returns:
-
str–Absolute name of the node (until given depth is reached).
Source code in src/dependenpy/_internal/node.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
LocalPackageFinder ¤
Bases: PackageFinder
Finder to find local packages (directories on the disk).
Methods:
-
find–Find method.
find ¤
find(package: str, **kwargs: Any) -> PackageSpec | None
Find method.
Parameters:
Returns:
-
PackageSpec | None–Package spec or None.
Source code in src/dependenpy/_internal/finder.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
Matrix ¤
Bases: PrintMixin
Matrix class.
A class to build a matrix given a list of nodes. After instantiation, it has two attributes: data, a 2-dimensions array, and keys, the names of the entities in the corresponding order.
Parameters:
-
*nodes(DSM | Package | Module, default:()) –The nodes on which to build the matrix.
-
depth(int, default:0) –The depth of the matrix. This depth is always absolute, meaning that building a matrix with a sub-package "A.B.C" and a depth of 1 will return a matrix of size 1, containing A only. To see the matrix for the sub-modules and sub-packages in C, you will have to give depth=4.
Methods:
-
cast–Cast a set of keys and an array to a Matrix object.
-
print–Print the object in a file or on standard output by default.
Attributes:
-
data–The data of the matrix.
-
keys–The keys of the matrix.
-
size–The size of the matrix.
-
total(int) –Return the total number of dependencies within this matrix.
Source code in src/dependenpy/_internal/structures.py
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
total property ¤
total: int
Return the total number of dependencies within this matrix.
Returns:
-
int–The total number of dependencies.
cast staticmethod ¤
Cast a set of keys and an array to a Matrix object.
Parameters:
Returns:
-
Matrix–A new matrix.
Source code in src/dependenpy/_internal/structures.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
print ¤
Print the object in a file or on standard output by default.
Parameters:
-
format(str | None, default:TEXT) –Output format (csv, json or text).
-
output(IO, default:stdout) –Descriptor to an opened file (default to standard output).
-
**kwargs(Any, default:{}) –Additional arguments.
Source code in src/dependenpy/_internal/helpers.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
Module ¤
Bases: LeafNode, NodeMixin, PrintMixin
Module class.
This class represents a Python module (a Python file).
Parameters:
-
name(str) –Name of the module.
-
path(str) –Path to the module.
-
dsm(DSM | None, default:None) –Parent DSM.
-
package(Package | None, default:None) –Parent Package.
Methods:
-
__contains__–Whether given item is contained inside this module.
-
absolute_name–Return the absolute name of the node.
-
as_dict–Return the dependencies as a dictionary.
-
build_dependencies–Build the dependencies for this module.
-
cardinal–Return the number of dependencies of this module to the given node.
-
get_imports–Return all the import statements given an AST body (AST nodes).
-
parse_code–Read the source code and return all the import statements.
-
print–Print the object in a file or on standard output by default.
Attributes:
-
RECURSIVE_NODES–Nodes that can be recursive.
-
dependencies(list[Dependency]) –List of dependencies.
-
depth(int) –Property to tell the depth of the node in the tree.
-
dsm–Parent DSM.
-
isdsm(bool) –Property to check if object is instance of DSM.
-
ismodule(bool) –Inherited from NodeMixin. Always True.
-
ispackage(bool) –Property to check if object is instance of Package.
-
name–Name of the module.
-
package–Package to which the module belongs.
-
path–Path to the module.
-
root(Package) –Property to return the root of this node.
Source code in src/dependenpy/_internal/dsm.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
RECURSIVE_NODES class-attribute instance-attribute ¤
RECURSIVE_NODES = (
ClassDef,
FunctionDef,
If,
IfExp,
Try,
With,
ExceptHandler,
)
Nodes that can be recursive.
ispackage property ¤
ispackage: bool
Property to check if object is instance of Package.
Returns:
-
bool–Whether this object is a package.
__contains__ ¤
Whether given item is contained inside this module.
Parameters:
Returns:
-
bool–True if self is item or item is self's package and self if an
__init__module.
Source code in src/dependenpy/_internal/dsm.py
274 275 276 277 278 279 280 281 282 283 284 285 286 | |
absolute_name ¤
Return the absolute name of the node.
Concatenate names from root to self within depth.
Parameters:
-
depth(int, default:0) –Maximum depth to go to.
Returns:
-
str–Absolute name of the node (until given depth is reached).
Source code in src/dependenpy/_internal/node.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
as_dict ¤
Return the dependencies as a dictionary.
Parameters:
-
absolute(bool, default:False) –Whether to use the absolute name.
Returns:
-
dict–Dictionary of dependencies.
Source code in src/dependenpy/_internal/dsm.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
build_dependencies ¤
build_dependencies() -> None
Build the dependencies for this module.
Parse the code with ast, find all the import statements, convert them into Dependency objects.
Source code in src/dependenpy/_internal/dsm.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
cardinal ¤
Return the number of dependencies of this module to the given node.
Parameters:
Returns:
-
int–Number of dependencies.
Source code in src/dependenpy/_internal/dsm.py
405 406 407 408 409 410 411 412 413 414 | |
get_imports ¤
Return all the import statements given an AST body (AST nodes).
Returns:
Source code in src/dependenpy/_internal/dsm.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
parse_code ¤
Read the source code and return all the import statements.
Returns:
Source code in src/dependenpy/_internal/dsm.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
print ¤
Print the object in a file or on standard output by default.
Parameters:
-
format(str | None, default:TEXT) –Output format (csv, json or text).
-
output(IO, default:stdout) –Descriptor to an opened file (default to standard output).
-
**kwargs(Any, default:{}) –Additional arguments.
Source code in src/dependenpy/_internal/helpers.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
NodeMixin ¤
Shared code between DSM, Package and Module.
Attributes:
Package ¤
Package(
name: str,
path: str,
dsm: DSM | None = None,
package: Package | None = None,
limit_to: list[str] | None = None,
build_tree: bool = True,
build_dependencies: bool = True,
enforce_init: bool = True,
)
Bases: RootNode, LeafNode, NodeMixin, PrintMixin
Package class.
This class represent Python packages as nodes in a tree.
Parameters:
-
name(str) –Name of the package.
-
path(str) –Path to the package.
-
dsm(DSM | None, default:None) –Parent DSM.
-
package(Package | None, default:None) –Parent package.
-
limit_to(list[str] | None, default:None) –List of string to limit the recursive tree-building to what is specified.
-
build_tree(bool, default:True) –Auto-build the tree or not.
-
build_dependencies(bool, default:True) –Auto-build the dependencies or not.
-
enforce_init(bool, default:True) –If True, only treat directories if they contain an
__init__.pyfile.
Methods:
-
__bool__–Node as Boolean.
-
__contains__–Get result of _contains, cache it and return it.
-
__getitem__–Return the corresponding Package or Module object.
-
absolute_name–Return the absolute name of the node.
-
as_dict–Return the dependencies as a dictionary.
-
as_graph–Create a graph with self as node, cache it, return it.
-
as_matrix–Create a matrix with self as node, cache it, return it.
-
as_treemap–Return the dependencies as a TreeMap.
-
build_dependencies–Recursively build the dependencies for sub-modules and sub-packages.
-
build_tree–Build the tree for this package.
-
cardinal–Return the number of dependencies of this package to the given node.
-
get–Get item through
__getitem__and cache the result. -
get_target–Get the result of _get_target, cache it and return it.
-
print–Print the object in a file or on standard output by default.
-
print_graph–Print the graph for self's nodes.
-
print_matrix–Print the matrix for self's nodes.
-
print_treemap–Print the matrix for self's nodes.
-
split_limits_heads–Return first parts of dot-separated strings, and rest of strings.
Attributes:
-
depth(int) –Property to tell the depth of the node in the tree.
-
dsm–Parent DSM.
-
empty(bool) –Whether the node has neither modules nor packages.
-
enforce_init–Whether to enforce the presence of
__init__.pyfiles. -
isdsm(bool) –Property to check if object is instance of DSM.
-
ismodule(bool) –Property to check if object is instance of Module.
-
ispackage(bool) –Inherited from NodeMixin. Always True.
-
isroot(bool) –Property to tell if this node is a root node.
-
issubpackage(bool) –Property to tell if this node is a sub-package.
-
limit_to–List of strings to limit the recursive tree-building.
-
modules(list[Module]) –List of modules contained in the node.
-
name–Name of the package.
-
package–Parent package.
-
packages(list[Package]) –List of packages contained in the node.
-
path–Path to the package.
-
root(Package) –Property to return the root of this node.
-
submodules(list[Module]) –Property to return all sub-modules of the node, recursively.
Source code in src/dependenpy/_internal/dsm.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
enforce_init instance-attribute ¤
enforce_init = enforce_init
Whether to enforce the presence of __init__.py files.
limit_to instance-attribute ¤
limit_to = limit_to or []
List of strings to limit the recursive tree-building.
submodules property ¤
__bool__ ¤
__bool__() -> bool
Node as Boolean.
Returns:
-
bool–Result of node.empty.
Source code in src/dependenpy/_internal/node.py
106 107 108 109 110 111 112 | |
__contains__ ¤
Get result of _contains, cache it and return it.
Parameters:
Returns:
-
bool–True if self contains item, False otherwise.
Source code in src/dependenpy/_internal/node.py
67 68 69 70 71 72 73 74 75 76 77 78 | |
__getitem__ ¤
Return the corresponding Package or Module object.
Parameters:
-
item(str) –Name of the package/module, dot-separated.
Raises:
-
KeyError–When the package or module cannot be found.
Returns:
Source code in src/dependenpy/_internal/node.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
absolute_name ¤
Return the absolute name of the node.
Concatenate names from root to self within depth.
Parameters:
-
depth(int, default:0) –Maximum depth to go to.
Returns:
-
str–Absolute name of the node (until given depth is reached).
Source code in src/dependenpy/_internal/node.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
as_dict ¤
as_dict() -> dict
Return the dependencies as a dictionary.
Returns:
-
dict–Dictionary of dependencies.
Source code in src/dependenpy/_internal/node.py
300 301 302 303 304 305 306 307 308 309 310 | |
as_graph ¤
Create a graph with self as node, cache it, return it.
Parameters:
-
depth(int, default:0) –Depth of the graph.
Returns:
-
Graph–An instance of Graph.
Source code in src/dependenpy/_internal/node.py
312 313 314 315 316 317 318 319 320 321 322 323 | |
as_matrix ¤
Create a matrix with self as node, cache it, return it.
Parameters:
-
depth(int, default:0) –Depth of the matrix.
Returns:
-
Matrix–An instance of Matrix.
Source code in src/dependenpy/_internal/node.py
325 326 327 328 329 330 331 332 333 334 335 336 | |
as_treemap ¤
as_treemap() -> TreeMap
Return the dependencies as a TreeMap.
Returns:
-
TreeMap–An instance of TreeMap.
Source code in src/dependenpy/_internal/node.py
338 339 340 341 342 343 344 345 346 | |
build_dependencies ¤
build_dependencies() -> None
Recursively build the dependencies for sub-modules and sub-packages.
Iterate on node's modules then packages and call their build_dependencies methods.
Source code in src/dependenpy/_internal/node.py
217 218 219 220 221 222 223 224 225 226 | |
build_tree ¤
build_tree() -> None
Build the tree for this package.
Source code in src/dependenpy/_internal/dsm.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
cardinal ¤
Return the number of dependencies of this package to the given node.
Parameters:
Returns:
-
int–Number of dependencies.
Source code in src/dependenpy/_internal/dsm.py
232 233 234 235 236 237 238 239 240 241 | |
get ¤
Get item through __getitem__ and cache the result.
Parameters:
-
item(str) –Name of package or module.
Returns:
Source code in src/dependenpy/_internal/node.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
get_target ¤
Get the result of _get_target, cache it and return it.
Parameters:
-
target(str) –Target to find.
Returns:
Source code in src/dependenpy/_internal/node.py
173 174 175 176 177 178 179 180 181 182 183 184 | |
print ¤
Print the object in a file or on standard output by default.
Parameters:
-
format(str | None, default:TEXT) –Output format (csv, json or text).
-
output(IO, default:stdout) –Descriptor to an opened file (default to standard output).
-
**kwargs(Any, default:{}) –Additional arguments.
Source code in src/dependenpy/_internal/helpers.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
print_graph ¤
print_graph(
format: str | None = None,
output: IO = stdout,
depth: int = 0,
**kwargs: Any,
) -> None
Print the graph for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
depth(int, default:0) –Depth of the graph.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
graph.print.
Source code in src/dependenpy/_internal/node.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
print_matrix ¤
print_matrix(
format: str | None = None,
output: IO = stdout,
depth: int = 0,
**kwargs: Any,
) -> None
Print the matrix for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
depth(int, default:0) –Depth of the matrix.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
matrix.print.
Source code in src/dependenpy/_internal/node.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
print_treemap ¤
Print the matrix for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
treemap.print.
Source code in src/dependenpy/_internal/node.py
264 265 266 267 268 269 270 271 272 273 | |
split_limits_heads ¤
Return first parts of dot-separated strings, and rest of strings.
Returns:
Source code in src/dependenpy/_internal/dsm.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
PackageFinder ¤
Abstract package finder class.
Methods:
-
find–Find method.
find ¤
find(package: str, **kwargs: Any) -> PackageSpec | None
Find method.
Parameters:
Returns:
-
PackageSpec | None–Package spec or None.
Source code in src/dependenpy/_internal/finder.py
74 75 76 77 78 79 80 81 82 83 84 | |
PackageSpec ¤
Holder for a package specification (given as argument to DSM).
Parameters:
-
name(str) –Name of the package.
-
path(str) –Path to the package.
-
limit_to(list[str] | None, default:None) –Limitations.
Methods:
-
__hash__–Hash method.
-
add–Add limitations of given spec to self's.
-
combine–Combine package specifications' limitations.
Attributes:
-
ismodule(bool) –Property to tell if the package is in fact a module (a file).
-
limit_to–List of limitations.
-
name–Name of the package.
-
path–Path to the package.
Source code in src/dependenpy/_internal/finder.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
ismodule property ¤
ismodule: bool
Property to tell if the package is in fact a module (a file).
Returns:
-
bool–Whether this package is in fact a module.
__hash__ ¤
__hash__()
Hash method.
The hash is computed based on the package name and path.
Source code in src/dependenpy/_internal/finder.py
26 27 28 29 30 31 | |
add ¤
add(spec: PackageSpec) -> None
Add limitations of given spec to self's.
Parameters:
-
spec(PackageSpec) –Another spec.
Source code in src/dependenpy/_internal/finder.py
42 43 44 45 46 47 48 49 50 | |
combine staticmethod ¤
combine(specs: list[PackageSpec]) -> list[PackageSpec]
Combine package specifications' limitations.
Parameters:
-
specs(list[PackageSpec]) –The package specifications.
Returns:
-
list[PackageSpec]–The new, merged list of PackageSpec.
Source code in src/dependenpy/_internal/finder.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
PrintMixin ¤
Print mixin class.
Methods:
-
print–Print the object in a file or on standard output by default.
print ¤
Print the object in a file or on standard output by default.
Parameters:
-
format(str | None, default:TEXT) –Output format (csv, json or text).
-
output(IO, default:stdout) –Descriptor to an opened file (default to standard output).
-
**kwargs(Any, default:{}) –Additional arguments.
Source code in src/dependenpy/_internal/helpers.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
RootNode ¤
RootNode(build_tree: bool = True)
Shared code between DSM and Package.
Parameters:
-
build_tree(bool, default:True) –Whether to immediately build the tree or not.
Methods:
-
__bool__–Node as Boolean.
-
__contains__–Get result of _contains, cache it and return it.
-
__getitem__–Return the corresponding Package or Module object.
-
as_dict–Return the dependencies as a dictionary.
-
as_graph–Create a graph with self as node, cache it, return it.
-
as_matrix–Create a matrix with self as node, cache it, return it.
-
as_treemap–Return the dependencies as a TreeMap.
-
build_dependencies–Recursively build the dependencies for sub-modules and sub-packages.
-
build_tree–To be overridden.
-
get–Get item through
__getitem__and cache the result. -
get_target–Get the result of _get_target, cache it and return it.
-
print_graph–Print the graph for self's nodes.
-
print_matrix–Print the matrix for self's nodes.
-
print_treemap–Print the matrix for self's nodes.
Attributes:
-
empty(bool) –Whether the node has neither modules nor packages.
-
modules(list[Module]) –List of modules contained in the node.
-
packages(list[Package]) –List of packages contained in the node.
-
submodules(list[Module]) –Property to return all sub-modules of the node, recursively.
Source code in src/dependenpy/_internal/node.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
submodules property ¤
__bool__ ¤
__bool__() -> bool
Node as Boolean.
Returns:
-
bool–Result of node.empty.
Source code in src/dependenpy/_internal/node.py
106 107 108 109 110 111 112 | |
__contains__ ¤
Get result of _contains, cache it and return it.
Parameters:
Returns:
-
bool–True if self contains item, False otherwise.
Source code in src/dependenpy/_internal/node.py
67 68 69 70 71 72 73 74 75 76 77 78 | |
__getitem__ ¤
Return the corresponding Package or Module object.
Parameters:
-
item(str) –Name of the package/module, dot-separated.
Raises:
-
KeyError–When the package or module cannot be found.
Returns:
Source code in src/dependenpy/_internal/node.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
as_dict ¤
as_dict() -> dict
Return the dependencies as a dictionary.
Returns:
-
dict–Dictionary of dependencies.
Source code in src/dependenpy/_internal/node.py
300 301 302 303 304 305 306 307 308 309 310 | |
as_graph ¤
Create a graph with self as node, cache it, return it.
Parameters:
-
depth(int, default:0) –Depth of the graph.
Returns:
-
Graph–An instance of Graph.
Source code in src/dependenpy/_internal/node.py
312 313 314 315 316 317 318 319 320 321 322 323 | |
as_matrix ¤
Create a matrix with self as node, cache it, return it.
Parameters:
-
depth(int, default:0) –Depth of the matrix.
Returns:
-
Matrix–An instance of Matrix.
Source code in src/dependenpy/_internal/node.py
325 326 327 328 329 330 331 332 333 334 335 336 | |
as_treemap ¤
as_treemap() -> TreeMap
Return the dependencies as a TreeMap.
Returns:
-
TreeMap–An instance of TreeMap.
Source code in src/dependenpy/_internal/node.py
338 339 340 341 342 343 344 345 346 | |
build_dependencies ¤
build_dependencies() -> None
Recursively build the dependencies for sub-modules and sub-packages.
Iterate on node's modules then packages and call their build_dependencies methods.
Source code in src/dependenpy/_internal/node.py
217 218 219 220 221 222 223 224 225 226 | |
build_tree ¤
build_tree() -> None
To be overridden.
Source code in src/dependenpy/_internal/node.py
136 137 138 | |
get ¤
Get item through __getitem__ and cache the result.
Parameters:
-
item(str) –Name of package or module.
Returns:
Source code in src/dependenpy/_internal/node.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
get_target ¤
Get the result of _get_target, cache it and return it.
Parameters:
-
target(str) –Target to find.
Returns:
Source code in src/dependenpy/_internal/node.py
173 174 175 176 177 178 179 180 181 182 183 184 | |
print_graph ¤
print_graph(
format: str | None = None,
output: IO = stdout,
depth: int = 0,
**kwargs: Any,
) -> None
Print the graph for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
depth(int, default:0) –Depth of the graph.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
graph.print.
Source code in src/dependenpy/_internal/node.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
print_matrix ¤
print_matrix(
format: str | None = None,
output: IO = stdout,
depth: int = 0,
**kwargs: Any,
) -> None
Print the matrix for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
depth(int, default:0) –Depth of the matrix.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
matrix.print.
Source code in src/dependenpy/_internal/node.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
print_treemap ¤
Print the matrix for self's nodes.
Parameters:
-
format(str | None, default:None) –Output format (csv, json or text).
-
output(IO, default:stdout) –File descriptor on which to write.
-
**kwargs(Any, default:{}) –Additional keyword arguments passed to
treemap.print.
Source code in src/dependenpy/_internal/node.py
264 265 266 267 268 269 270 271 272 273 | |
TreeMap ¤
Bases: PrintMixin
TreeMap class.
Parameters:
-
*nodes(Any, default:()) –the nodes from which to build the treemap.
-
value(int, default:-1) –the value of the current area.
Methods:
-
print–Print the object in a file or on standard output by default.
Attributes:
-
value–The value of the current area.
Source code in src/dependenpy/_internal/structures.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
print ¤
Print the object in a file or on standard output by default.
Parameters:
-
format(str | None, default:TEXT) –Output format (csv, json or text).
-
output(IO, default:stdout) –Descriptor to an opened file (default to standard output).
-
**kwargs(Any, default:{}) –Additional arguments.
Source code in src/dependenpy/_internal/helpers.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
Vertex ¤
Vertex(name: str)
Vertex class. Used in Graph class.
Parameters:
-
name(str) –name of the vertex.
Methods:
-
connect_from–Connect another vertex to this one.
-
connect_to–Connect this vertex to another one.
Attributes:
-
edges_in(set[Edge]) –Incoming edges.
-
edges_out(set[Edge]) –Outgoing edges.
-
name–Name of the vertex.
Source code in src/dependenpy/_internal/structures.py
203 204 205 206 207 208 209 210 211 212 213 214 | |
connect_from ¤
Connect another vertex to this one.
Parameters:
Returns:
-
Edge–The newly created edge.
Source code in src/dependenpy/_internal/structures.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
connect_to ¤
Connect this vertex to another one.
Parameters:
Returns:
-
Edge–The newly created edge.
Source code in src/dependenpy/_internal/structures.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
get_parser ¤
get_parser() -> ArgumentParser
Return the CLI argument parser.
Returns:
-
ArgumentParser–An argparse parser.
Source code in src/dependenpy/_internal/cli.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
guess_depth ¤
Guess the optimal depth to use for the given list of arguments.
Parameters:
Returns:
-
int–Guessed depth to use.
Source code in src/dependenpy/_internal/helpers.py
54 55 56 57 58 59 60 61 62 63 64 65 | |
main ¤
Run the main program.
This function is executed when you type dependenpy or python -m dependenpy.
Parameters:
Returns:
-
int–An exit code. 0 (OK), 1 (dsm empty) or 2 (error).
Source code in src/dependenpy/_internal/cli.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |