在其他模块之间建立依赖关系矩阵的python模块。
dependenp的Python项目详细描述
依赖性
dependenpy允许您为一组python包构建依赖关系矩阵。 为此,它读取并搜索源代码中的import语句。
许可证
根据ISC许可证授权的软件。
安装
pip install dependenpy
使用量
版本3引入了一个命令行工具:
示例:
dependenpy -h
结果:
usage: dependenpy [-d DEPTH][-f {csv,json,text}][-g][-G][-h][-i INDENT][-l][-m][-o OUTPUT][-t][-v] PACKAGES [PACKAGES ...] Command line tool for dependenpy Python package. positional arguments: PACKAGES The package list. Can be a comma-separated list. Each package must be either a valid path or a package in PYTHONPATH. optional arguments: -d DEPTH, --depth DEPTH Specify matrix or graph depth. Default: best guess. -f {csv,json,text}, --format {csv,json,text} Output format. Default: text. -g, --show-graph Show the graph (no text format). Default: false. -G, --greedy Explore subdirectories even if they do not contain an __init__.py file. Can make execution slower. Default: false. -h, --help Show this help message and exit. -i INDENT, --indent INDENT Specify output indentation. CSV will never be indented. Text will always have new-lines. JSON can be minified with a negative value. Default: best guess. -l, --show-dependencies-list Show the dependencies list. Default: false. -m, --show-matrix Show the matrix. Default: true unless -g, -l or -t. -o OUTPUT, --output OUTPUT Output to given file. Default: stdout. -t, --show-treemap Show the treemap (work in progress). Default: false. -v, --version Show the current version of the program and exit.
示例:
dependenpy dependenpy dependenpy dependenpy --depth=2
结果:
Module | Id ||0|1|2|3|4|5|6|7|8| ----------------------+----++-+-+-+-+-+-+-+-+-+ dependenpy.__init__ |0||0|0|0|4|0|0|0|0|2| dependenpy.__main__ |1||0|0|1|0|0|0|0|0|0| dependenpy.cli |2||1|0|0|1|0|4|0|0|0| dependenpy.dsm |3||0|0|0|0|2|1|3|0|0| dependenpy.finder |4||0|0|0|0|0|0|0|0|0| dependenpy.helpers |5||0|0|0|0|0|0|0|0|0| dependenpy.node |6||0|0|0|0|0|0|0|0|3| dependenpy.plugins |7||0|0|0|1|0|1|0|0|0| dependenpy.structures |8||0|0|0|0|0|1|0|0|0|
您也可以通过编程方式使用dependenpy:
fromdependenpyimportDSM# create DSMdsm=DSM('django')# transform as matrixmatrix=dsm.as_matrix(depth=2)# initialize with many packagesdsm=DSM('django','meerkat','appsettings','dependenpy','archan')withopen('output','w')asoutput:dsm.print(format='json',indent=2,output=output)# access packages and modulesmeerkat=dsm['meerkat']# or dsm.get('meerkat')finder=dsm['dependenpy.finder']# or even dsm['dependenpy']['finder']# instances of DSM and Package all have print, as_matrix, etc. methodsmeerkat.print_matrix(depth=2)
这个包最初是设计用于Django项目的。 django包django-meerkat使用它来显示带有highcharts的矩阵。
发展
运行所有测试:tox
更改日志
3.2.0(2017-06-27)
- 将--greedy的-gshort选项更改为-G。
- 添加带有相关图形类和功能的-g,--show-graph选项。
- 为archan(dependenpy.plugins.InternalDependencies)添加提供程序。
- 相应地更新文档。
3.1.0(2017-06-02)
- 将-i,--enforce-init选项更改为相反的-g,--greedy。
- 添加-i,--indent选项以指定缩进级别。
- 选项-l、-m和-t现在是互斥的。
- 修复深度0的矩阵生成。
- 印刷方法已经改进。
- 更新文档。
3.0.0(2017-05-23)
这个版本是一个很大的重构。代码更加面向对象, 更干净,更短,更简单,更聪明,更方便用户-简而言之:更好。
附加功能:
- 命令行入口点,
- 现在捕获运行时静态导入(在函数或类中)。 以及import语句(以前仅从import)。
2.0.3(2017-04-20)
- 修复读取utf-8文件时偶尔出现的unicodeencode。
- 使用ast解析时处理文件中的错误字符。
0.1.0至2.0.2(2016-10-06)
- 开发(alpha然后beta版本)。
0.1.0(2016-10-06)
- PYPI上的α释放。