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

Diff of /src/packages/query_ebuild.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20