>/tmp/check.txt
for file in `ls *.py`
do
    awk -F "(" '{
        if ($0 ~ /^def/) {
            print $0
        }
}' $file >> /tmp/check.txt
done

python <<!
f = file("/tmp/check.txt", "r")
lines = f.readlines()
unique=set(lines)
if len(lines) != len(unique):
    for n in unique:
        lines.remove(n)
    print "=== duplicate function ==="
    for l in lines:
        print l.strip()
!                    

  从*.py文件中找重复的代码。

posted on 2013-11-15 17:52  houxiurong.com  阅读(310)  评论(0编辑  收藏  举报
< a href="http://houxiurong.com">houxiurong.com