Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On Sun, 2011-01-09 at 12:29 +0100, Julien Nabet wrote:
Hello,

I run the whole process for retrieving a fresh report of callcatchers.
I hope having using callcatcher in the right way and that it will help

Here's my original script for mercurial based OpenOffice.org runs

The catch is that if you just analyze a single library then you get get
methods reported as unused that are not used inside the library by
anything but are used by some other library not included on the command
line.

So the below script analyzes the libs in OOo on which nothing depends,
or those which have export files that restrict the list of methods
exported.

So this might serve as a better basis for a script to get the
low-hanging ones.

C.

Attachment: runbot.sh
Description: application/shellscript

#!/bin/env python

import sys, glob, os, difflib

def getunused(adir):
        retmap = {}
        rettotal = 0
        os.chdir(adir)
        files = glob.glob("*callcatcher.log")
        for file in files:
                unused = len(open(file).readlines())
                retmap[file] = unused
                rettotal += unused
        os.chdir("..")

        return retmap, rettotal

def sorttolist(amap):
        retlist = []
        for a in amap.keys():
                retlist.append([amap[a], a])

        retlist.sort()
        retlist.reverse()

        return retlist


new, newtotal = getunused(sys.argv[1])
newlist = sorttolist(new)
old, oldtotal = getunused(sys.argv[2])

print '<html><head>'
print '<title>'+sys.argv[1]+'</title>'
print '<SCRIPT LANGUAGE="JavaScript" SRC="../support/mktree.js"></SCRIPT>'
print '<LINK REL="stylesheet" HREF="../support/mktree.css"/>'
print '</head><body>'
print '<h1>'+sys.argv[1]+'</h1>'
diff = newtotal-oldtotal
print '<h3> Total:', newtotal, 'unused methods'
if diff > 0:
        print '+'+str(diff),
elif diff < 0:
        print diff,
print "</h3>"

print '<ul class="mktree" id="tree1">'
for entry in newlist:
        if entry[0] > 0 or (old.has_key(entry[1]) and old[entry[1]] > 0):
                print '<li>',
                print entry[0],
                if entry[0] > 0:
                        print '<a href="'+entry[1]+'">'+entry[1]+'</a>',
                else:
                        print entry[1],
                diff = entry[0]
                if old.has_key(entry[1]):
                        diff = entry[0]-old[entry[1]]
                if diff > 0:
                        print '+'+str(diff),
                elif diff < 0:
                        print diff,
                if diff != 0:
                        print '<ul>'
                        d = difflib.Differ()
                        oldlines = []
                        try:
                                oldlines = open(sys.argv[2]+'/'+entry[1]).readlines()
                        except:
                                pass
                        newlines = []
                        try:
                                newlines = open(sys.argv[1]+'/'+entry[1]).readlines()
                        except:
                                pass
                        result = list(d.compare(oldlines, newlines))
                        for line in result:
                                if line[0] == '+' or line[0] == '-':
                                        print '<li>',line,'</li>'
                        print '</ul>'
                print '</li>'
print '</ul>'
print "</body></html>"

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.