From 0adb6d01f137435bdb72a02b264b08cd60f94074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrer=20=C3=96zen?= Date: Sat, 13 Aug 2005 14:05:50 +0000 Subject: [PATCH] =?UTF-8?q?Bir=20pisi=20source=20deposuna=20ait=20=C3=A7e?= =?UTF-8?q?=C5=9Fitli=20istatistikleri=20=C3=A7=C4=B1karmak=20i=C3=A7in=20?= =?UTF-8?q?bir=20ara=C3=A7,=20depodaki=20specleri=20kontrol=20etmek=20i?= =?UTF-8?q?=C3=A7in=20de=20i=C5=9Fe=20yar=C4=B1yor.=20pisi.specfile=20kull?= =?UTF-8?q?an=C4=B1yor.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi.e3p | 16 +++++---- tools/repostats.py | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 7 deletions(-) create mode 100755 tools/repostats.py diff --git a/pisi.e3p b/pisi.e3p index 5f6fe359..f9bbb0d7 100644 --- a/pisi.e3p +++ b/pisi.e3p @@ -1,16 +1,14 @@ - + - + - - Python - Kde + The package management software of Pardus distribution. - 0.2 + 0.2 PiSi Development Team - pisi@uludag.org.tr + pisi@uludag.org.tr tools @@ -308,6 +306,10 @@ actionsapi pisitoolsfunctions.py + + tools + repostats.py + diff --git a/tools/repostats.py b/tools/repostats.py new file mode 100755 index 00000000..361b9c40 --- /dev/null +++ b/tools/repostats.py @@ -0,0 +1,88 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (C) 2005, TUBITAK/UEKAE +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# + +import sys +import os + +import pisi.specfile + +class Histogram: + def __init__(self): + self.list = {} + + def add(self, name): + if self.list.has_key(name): + self.list[name] = self.list[name] + 1 + else: + self.list[name] = 1 + + def _sortfunc(self, x, y): + if x[1] > y[1]: + return -1 + elif x[1] == y[1]: + return 0 + else: + return 1 + + def get_list(self): + items = self.list.items() + items.sort(self._sortfunc) + return items + + +def echo(string): + print string.encode("utf8") + +def scan_pspec(folder): + paks = [] + for root, dirs, files in os.walk(folder): + if "pspec.xml" in files: + paks.append(root) + # dont walk into the versioned stuff + if ".svn" in dirs: + dirs.remove(".svn") + return paks + +people = Histogram() +licenses = Histogram() +mostp_name = None +mostp_count = 0 + +for pak in scan_pspec(sys.argv[1]): + spec = pisi.specfile.SpecFile() + spec.read(os.path.join(pak, "pspec.xml")) + 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 + people.add(name) + for lice in lices: + licenses.add(lice) + +print "%s İstatistikleri" % (sys.argv[1]) +print '' +print "" + +print "

Paketleyiciler

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

Lisanslar

" +for name,cnt in licenses.get_list(): + print "" % (name, cnt) +print "
%s%s
" + +if mostp_count > 0: + echo(u"

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

" % (mostp_count, mostp_name)) + +print ""