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

Contents of /src/packages/query_ebuild.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download) (as text)
Thu May 27 02:29:48 2004 UTC (10 years, 3 months ago) by marduk
Branch: MAIN
Changes since 1.1: +32 -30 lines
File MIME type: text/x-python
Oh, this is a big update: code cleanups, HTML cleanups, support for hard
masked packages and smart, er, less-brain-dead search reporting.

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

  ViewVC Help
Powered by ViewVC 1.1.20