/[gentoo]/src/packages/categories2.py
Gentoo

Contents of /src/packages/categories2.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Thu May 27 05:03:40 2004 UTC (10 years, 3 months ago) by marduk
Branch: MAIN
CVS Tags: v1_3_1, release_1-5, HEAD
Branch point for: pre_2-0, v1_3
File MIME type: text/x-python
We use categories2.py, not categories.py to generate the categories page.
Also removed config.py to prevent overwriting it on the server.

1 #!/usr/bin/python -OO
2
3 import time
4 import MySQLdb
5 import ebuilddb
6 import config
7 import gentoo
8
9 COLS=5
10
11 def get_categories():
12 db = ebuilddb.db_connect()
13 c = db.cursor()
14 query = ('SELECT category,COUNT(DISTINCT(name)) '
15 'FROM ebuild '
16 'GROUP BY category '
17 'ORDER BY category ')
18 #print query
19 c.execute(query)
20 results = c.fetchall()
21 return results
22
23
24 if __name__ == '__main__':
25 print '<table class="categories">'
26 results = get_categories()
27 total = len(results)
28 row_count = total / COLS
29 if (total % COLS):
30 row_count = row_count + 1
31 cols = [[] for i in range(5)]
32 package_total = 0
33 current_col = 0
34 for result in results:
35 if len(cols[current_col]) == row_count:
36 current_col = current_col + 1
37 category, count = result
38 package_total = package_total + count
39 cols[current_col].append(result)
40 #cols[current_col].extend([('',0)]* row_count)
41 for i in range(row_count):
42 print '\n\t'.join(['<tr>'] + [('<td class="category">'
43 '<a href="%spackages/?category=%s">%s (%d)</a></td>' %
44 (config.FEHOME, category, category, count)) for
45 category, count in [x[i] for x in cols if len(x) > i] ] + ['</tr>'])
46 print '</table>\n'
47 print ('<div class="summary">A total of %d packages exist '
48 'in portage.</div>' % package_total)

  ViewVC Help
Powered by ViewVC 1.1.20