/[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.1.1 Revision 1.4
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 pieces = gentoo.pkgsplit(ebuild)
24 name = ebuild[:pos] 26 name = pieces[0]
25 version = ebuild[pos+1:] 27 if pieces[2] == 'r0':
28 version = pieces[1]
29 else:
30 version = '-'.join(pieces[1:])
26 db = ebuilddb.db_connect() 31 db = ebuilddb.db_connect()
27 # query 32 # query
28 query = ('SELECT ebuild.category,ebuild.name,version,when_found,' 33 query = ('SELECT ebuild.category,ebuild.name,version,when_found,'
29 'description,changelog,arch,homepage,license ' 34 'description,changelog,arch,homepage,license,is_masked '
30 'FROM ebuild,package WHERE ebuild.name="%s" AND ' 35 'FROM ebuild,package WHERE ebuild.name="%s" AND '
31 'version="%s" AND ' 36 'version="%s" AND '
32 'ebuild.name=package.name AND ebuild.category=package.category ' 37 'ebuild.name=package.name AND ebuild.category=package.category '
33 'ORDER by when_found DESC LIMIT 1' % (name,version)) 38 'ORDER by when_found DESC LIMIT 1' % (name,version))
34 #print query 39 #print query
35 c = db.cursor() 40 c = db.cursor()
36 c.execute(query) 41 c.execute(query)
37 result = c.fetchone() 42 result = c.fetchone()
38 if result: 43 if result:
39 #print result 44 #print result
40 eb = gentoo.query_to_dict(result) 45 eb = gentoo.query_to_dict(result)
41 sys.stdout.write(gentoo.ebuild_to_html(eb)) 46 sys.stdout.write(gentoo.ebuild_to_html(eb,show_bugs=0, full=True))
42 sys.exit(0) 47 sys.exit(0)
43 # else 404 48 # else 404
44 else: 49 else:
45 send_file = os.path.join(PKG_DIR,"%s.html" % DEFAULT) 50 send_file = os.path.join(PKG_DIR,"%s.html" % DEFAULT_EBUILD)
46 51
47sys.stdout.write(open(send_file,"r").read()) 52sys.stdout.write(open(send_file,"r").read())
48sys.stdout.flush() 53sys.stdout.flush()

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.20