Bir pisi source deposuna ait çeşitli istatistikleri çıkarmak

için bir araç, depodaki specleri kontrol etmek için de işe
yarıyor. pisi.specfile kullanıyor.
This commit is contained in:
Gürer Özen
2005-08-13 14:05:50 +00:00
parent 4041388913
commit 0adb6d01f1
2 changed files with 97 additions and 7 deletions
+9 -7
View File
@@ -1,16 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-3.7.dtd">
<!DOCTYPE Project SYSTEM "Project-3.5.dtd">
<!-- Project file for project pisi -->
<!-- Saved: 2005-08-11, 04:30:17 -->
<!-- Saved: 2005-08-13, 17:04:57 -->
<!-- Copyright (C) 2005 PiSi Development Team, pisi@uludag.org.tr -->
<Project version="3.7">
<ProgLanguage mixed="0">Python</ProgLanguage>
<UIType>Kde</UIType>
<Project version="3.5">
<Description>The package management software of Pardus distribution.
</Description>
<Version>0.2</Version>
<VersIon>0.2</VersIon>
<Author>PiSi Development Team</Author>
<Email>pisi@uludag.org.tr</Email>
<EmaIl>pisi@uludag.org.tr</EmaIl>
<Sources>
<Source>
<Dir>tools</Dir>
@@ -308,6 +306,10 @@
<Dir>actionsapi</Dir>
<Name>pisitoolsfunctions.py</Name>
</Source>
<Source>
<Dir>tools</Dir>
<Name>repostats.py</Name>
</Source>
</Sources>
<Forms>
</Forms>
+88
View File
@@ -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 "<html><head><title>%s İstatistikleri</title>" % (sys.argv[1])
print '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
print "</head><body>"
print "<h1>Paketleyiciler</h1><table>"
for name,cnt in people.get_list():
echo("<tr><td>%s</td><td>%s</td>" % (name, cnt))
print "</table>"
print "<h1>Lisanslar</h1><table>"
for name,cnt in licenses.get_list():
print "<tr><td>%s</td><td>%s</td>" % (name, cnt)
print "</table>"
if mostp_count > 0:
echo(u"<p>En çok peçlenen yazılım %d peçle %s!</p>" % (mostp_count, mostp_name))
print "</body>"