#!/usr/bin/python -OO import sys import config import cgi import gentoo import os import re from MySQLdb import escape_string form = cgi.FieldStorage() type = form.getvalue("type","") sstring = form.getvalue("sstring","") offset = form.getvalue("offset","0") if not sstring: sys.exit(0) if type == 'desc': col = "description" else: col = "name" def query_to_dict(q): pkginfo = {} keys = ('category','name','homepage','description','license') for i in range(len(keys)): try: pkginfo[keys[i]] = q[i] except IndexError: continue return pkginfo def write_to_cache(s): try: open(cachefile,'w').write(s) except IOError: pass def sort_by_weight(a, b): """Right now we just sort based on whether the sstring is in the name""" a_name = a['name'] b_name = b['name'] a_match = re.search(sstring, a_name, re.IGNORECASE) b_match = re.search(sstring, b_name, re.IGNORECASE) if a_match and b_match: return 0 if a_match: return -1 return 1 # if it's in the cache, just write that out qs = sys.argv[1] cachefile = os.path.join(config.LOCALHOME,'search/cache',qs) if os.path.exists(cachefile): #sys.stdout.write('
'
'Nothing found. | ||
'
' I could not find any ebuild that match' ' your query. Try a different query or check the' ' ' 'packages.gentoo.org main page. |