为类的方法构建依赖关系图的 Python 工具 [英] Python tool that builds a dependency diagram for methods of a class

查看:44
本文介绍了为类的方法构建依赖关系图的 Python 工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个巨大的遗留 Python 类,它有很多方法.我最终将复杂的分解成更小的部分,这样方法的数量就会增加更多.我想知道是否有一个工具可以扫描 Python 代码并为其方法构建某种依赖关系图.

如果 x()x() 中至少被调用一次,我将方法 x() 定义为方法 y() 的依赖项代码>y().

我可以使用这样的工具来隔离(如果可能)没有外部依赖项的类方法的子集(它们的所有依赖项都是来自同一子集的方法).

我计划将一些功能移到其他类中,我认为这种方法将帮助我决定从最初的大类中提取哪些部分.

我真的很想要一个命令行工具.

解决方案

你看过 Snakefood 了吗?看起来这正是您要找的.

I'm digging into a huge legacy Python class that has a lot of methods. I eventually break complex ones into smaller pieces so the amount of methods increases even more. I wonder if there is a tool that can scan the Python code and build some kind of dependency diagram for its methods.

I define method x() to be a dependency of method y() if x() is called at least once in y().

I could use such a tool to isolate (if possible) subsets of class methods that have no external dependencies (all their dependencies are methods from the same subset).

I'm planning to move some functionality into other classes and I think that such an approach would help me to decide which parts to extract from the initial huge class.

Edit: I would really like a command-line tool.

解决方案

Have you looked at Snakefood yet? It looks like it's exactly what you're looking for.

这篇关于为类的方法构建依赖关系图的 Python 工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆