diff --git a/tools/repostats.py b/tools/repostats.py index b52b2ddf..ad7c6124 100755 --- a/tools/repostats.py +++ b/tools/repostats.py @@ -14,6 +14,7 @@ import os sys.path.append('.') import pisi.specfile +import pisi.purl class Histogram: def __init__(self): @@ -52,27 +53,66 @@ def scan_pspec(folder): dirs.remove(".svn") return paks +hosts = Histogram() people = Histogram() licenses = Histogram() +components = Histogram() mostp_name = None mostp_count = 0 +nr_binpaks = 0 +nr_patches = 0 -for pak in scan_pspec(sys.argv[1]): +errors = [] + +paks = scan_pspec(sys.argv[1]) +for pak in paks: spec = pisi.specfile.SpecFile() - spec.read(os.path.join(pak, "pspec.xml")) + try: + spec.read(os.path.join(pak, "pspec.xml")) + except Exception, inst: + errors.append([pak, str(inst)]) + continue + if spec.verify() is False: + errors.append([pak, "specfile verification failed"]) + continue + nr_binpaks += len(spec.packages) + nr_patches += len(spec.source.patches) if len(spec.source.patches) > mostp_count: mostp_count = len(spec.source.patches) mostp_name = spec.source.name name = spec.source.packager.name lices = spec.source.license + partof = spec.source.partof + if partof: + components.add(partof) people.add(name) for lice in lices: licenses.add(lice) + host = pisi.purl.PUrl(spec.source.archiveUri).location() + hosts.add(host) print "%s İstatistikleri" % (sys.argv[1]) print '' print "" +print "

Toplam %d kod paketi, ve bunlardan oluşturulacak %d ikili paket var.

" % (len(paks), nr_binpaks) +echo(u"

Toplam peç sayısı %d

" % nr_patches) +if mostp_count > 0: + echo(u"

En çok peçlenen yazılım %d peçle %s!

" % (mostp_count, mostp_name)) + +if errors != []: + print "

Hatalar

" + for e in errors: + print "" % (e[0], e[1]) + print "
%s%s
" +else: + print "

Hata yok, tebrikler!

" + +print "

Komponentler

" +for name,cnt in components.get_list(): + print "" % (name, cnt) +print "
%s%s
" + print "

Paketleyiciler

" for name,cnt in people.get_list(): echo("" % (name, cnt)) @@ -83,7 +123,9 @@ for name,cnt in licenses.get_list(): print "" % (name, cnt) print "
%s%s
%s%s
" -if mostp_count > 0: - echo(u"

En çok peçlenen yazılım %d peçle %s!

" % (mostp_count, mostp_name)) +echo(u"

Kod kaynakları

") +for name,cnt in hosts.get_list(): + print "" % (name, cnt) +print "
%s%s
" print ""