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

Contents of /src/packages/query_ebuild.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Thu Feb 19 01:49:53 2004 UTC (10 years, 5 months ago) by marduk
Branch: MAIN
Branch point for: packages_g_o
File MIME type: text/x-python
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.20