]> git.decadent.org.uk Git - dak.git/blobdiff - dak/stats.py
Merge branch 'psycopg2' into content_generation
[dak.git] / dak / stats.py
old mode 100644 (file)
new mode 100755 (executable)
index bf84efe..105bf6c
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Various statistical pr0nography fun and games
+""" Various statistical pr0nography fun and games """
 # Copyright (C) 2000, 2001, 2002, 2003, 2006  James Troup <james@nocrew.org>
 
 # This program is free software; you can redistribute it and/or modify
@@ -32,7 +32,7 @@
 
 import pg, sys
 import apt_pkg
-import daklib.utils
+from daklib import utils
 
 ################################################################################
 
@@ -71,8 +71,8 @@ SELECT a.arch_string as Architecture, sum(f.size)
 
 def daily_install_stats():
     stats = {}
-    file = daklib.utils.open_file("2001-11")
-    for line in file.readlines():
+    f = utils.open_file("2001-11")
+    for line in f.readlines():
         split = line.strip().split('|')
         program = split[1]
         if program != "katie" and program != "process-accepted":
@@ -140,15 +140,15 @@ def number_of_packages():
     q = projectB.query("SELECT id, suite_name FROM suite")
     suite_ql = q.getresult()
     for i in suite_ql:
-        (id, name) = i
-        suites[id] = name
-        suite_ids[name] = id
+        (sid, name) = i
+        suites[sid] = name
+        suite_ids[name] = sid
     # Build up architecture mapping
     q = projectB.query("SELECT id, arch_string FROM architecture")
     for i in q.getresult():
-        (id, name) = i
-        arches[id] = name
-        arch_ids[name] = id
+        (aid, name) = i
+        arches[aid] = name
+        arch_ids[name] = aid
     # Pre-create the dictionary
     for suite_id in suites.keys():
         d[suite_id] = {}
@@ -213,7 +213,7 @@ SELECT suite, count(suite) FROM src_associations GROUP BY suite;""")
 def main ():
     global Cnf, projectB
 
-    Cnf = daklib.utils.get_conf()
+    Cnf = utils.get_conf()
     Arguments = [('h',"help","Stats::Options::Help")]
     for i in [ "help" ]:
         if not Cnf.has_key("Stats::Options::%s" % (i)):
@@ -226,10 +226,10 @@ def main ():
         usage()
 
     if len(args) < 1:
-        daklib.utils.warn("dak stats requires a MODE argument")
+        utils.warn("dak stats requires a MODE argument")
         usage(1)
     elif len(args) > 1:
-        daklib.utils.warn("dak stats accepts only one MODE argument")
+        utils.warn("dak stats accepts only one MODE argument")
         usage(1)
     mode = args[0].lower()
 
@@ -242,7 +242,7 @@ def main ():
     elif mode == "daily-install":
         daily_install_stats()
     else:
-        daklib.utils.warn("unknown mode '%s'" % (mode))
+        utils.warn("unknown mode '%s'" % (mode))
         usage(1)
 
 ################################################################################