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

Contents of /src/packages/query_ebuild.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download) (as text)
Tue Oct 4 01:44:45 2005 UTC (9 years, 1 month ago) by marduk
Branch: MAIN
CVS Tags: release_1-5, v1_3_1, HEAD
Branch point for: v1_3
Changes since 1.3: +3 -3 lines
File MIME type: text/x-python
* get mask info from is_masked column
* used inline pkgsplit() to avoid having to import portage (which is slow)

1 #!/usr/bin/python
2
3 import cgi
4 import os
5 import sys
6 import config
7 import gentoo,ebuilddb
8
9 DEFAULT_EBUILD = "404"
10 PKG_DIR = config.EBUILD_FILES
11
12 if len(sys.argv):
13 ebuild = sys.argv[1]
14 else:
15 ebuild = DEFAULT_EBUILD
16
17
18 html_file = os.path.join(PKG_DIR,"%s.html" % ebuild.replace('..',''))
19 #if os.path.exists(html_file):
20 if 0:
21 send_file = html_file
22 else:
23 # let's try the database
24 # connect
25 pieces = gentoo.pkgsplit(ebuild)
26 name = pieces[0]
27 if pieces[2] == 'r0':
28 version = pieces[1]
29 else:
30 version = '-'.join(pieces[1:])
31 db = ebuilddb.db_connect()
32 # query
33 query = ('SELECT ebuild.category,ebuild.name,version,when_found,'
34 'description,changelog,arch,homepage,license,is_masked '
35 'FROM ebuild,package WHERE ebuild.name="%s" AND '
36 'version="%s" AND '
37 'ebuild.name=package.name AND ebuild.category=package.category '
38 'ORDER by when_found DESC LIMIT 1' % (name,version))
39 #print query
40 c = db.cursor()
41 c.execute(query)
42 result = c.fetchone()
43 if result:
44 #print result
45 eb = gentoo.query_to_dict(result)
46 sys.stdout.write(gentoo.ebuild_to_html(eb,show_bugs=0, full=True))
47 sys.exit(0)
48 # else 404
49 else:
50 send_file = os.path.join(PKG_DIR,"%s.html" % DEFAULT_EBUILD)
51
52 sys.stdout.write(open(send_file,"r").read())
53 sys.stdout.flush()

  ViewVC Help
Powered by ViewVC 1.1.20