I'm wondering if anyone has had any luck using the Eclipse Metrics Plugin with Projects that are not in Java (specifically I'm trying to generate code metrics for a couple of PyDev Projects). I've read through the walk-through for the Metrics project but it indicates that I should be in the Java Perspective before accessing the Properties for my Project and that I should find a Metrics section. I don't get that for my PyDev Projects regardless of which Perspective I have open. Any suggestions or advice would be great.
+1
A:
I don't know if it's doable to get the plugin to work with pydev projects, but if it's just the lines-of-code
metric you are after, you could run this snippet in your project's root directory:
# 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)
ChristopheD
2010-07-09 19:22:42
That did what I needed it to. Thanks!
g.d.d.c
2010-07-09 19:32:12