我想知道是否有人幸运地使用了 Eclipse Metrics使用非 Java 项目的插件(具体来说,我正在尝试为几个 PyDev 项目生成代码指标)。我已经通读了 Metrics 项目的演练,但它表明在访问我的项目的 Properties 之前我应该在 Java Perspective 中,并且我应该找到 Metrics 部分。无论我打开哪个 Perspective,我的 PyDev 项目都不会得到它。任何建议或建议都会很棒。
最佳答案
我不知道让插件与 pydev 项目一起工作是否可行,但如果它只是你追求的 lines-of-code
指标,你可以在你的项目根目录:
# prints recursive count of lines of python source code from current directory
# includes an ignore_list. also prints total sloc
import os
cur_path = os.getcwd()
ignore_set = set(["__init__.py", "count_sourcelines.py"])
loclist = []
for pydir, _, pyfiles in os.walk(cur_path):
for pyfile in pyfiles:
if pyfile.endswith(".py") and pyfile not in ignore_set:
totalpath = os.path.join(pydir, pyfile)
loclist.append( ( len(open(totalpath, "r").read().splitlines()),
totalpath.split(cur_path)[1]) )
for linenumbercount, filename in loclist:
print "%05d lines in %s" % (linenumbercount, filename)
print "\nTotal: %s lines (%s)" %(sum([x[0] for x in loclist]), cur_path)
关于python - Eclipse PyDev 项目中的代码行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3214245/