Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 37916 Details for
Bug 51704
MySQL cache backend for portage
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
simple search script to replace esearch
myportage-search.py (text/plain), 3.21 KB, created by
Ahmed Farid
on 2004-08-22 01:40:30 UTC
(
hide
)
Description:
simple search script to replace esearch
Filename:
MIME Type:
Creator:
Ahmed Farid
Created:
2004-08-22 01:40:30 UTC
Size:
3.21 KB
patch
obsolete
>#!/usr/bin/python -O >import MySQLdb, sys >from re import split as re_split >from datetime import datetime >from output import bold, red, blue, green, darkgreen >uniq = {} >__author__ = "Ahmed Farid" >__version__ = "0.2" >if len(sys.argv) == 1 or sys.argv[1] == '-h': > print bold('This is a simple module to search through the portage mysql cache.') > print 'Mysql version: %s, MySQLdb version : %s, myportage-search.py version : %s' % (bold(MySQLdb.get_client_info()), bold(MySQLdb.__version__), bold(__version__)) > print "usage : " + bold(sys.argv[0])+ " [ " + green('options') + " ] [" + green('-h') +"] keyword" > print ' ' + green('-S') + '\tSearch description' > print ' ' + green('-K') + '\tSearch keywords' > print ' ' + green('-C') + '\tSearch categories' > print ' ' + green('-H') + '\tSearch homepages' > print ' ' + green('-L') + '\tSearch licences' > print ' ' + green('-U') + '\tSearch USE flags' > print ' ' + green('-P') + '\tSearch PROVIDES' > print ' ' + green('-h') + '\tDisplay this message' > sys.exit(1) >ex = MySQLdb.escape_string >col = 't1.name' >txt = ' '.join(sys.argv[1:]) >if sys.argv[1] == '-S': col = 't2.DESCRIPTION' >if sys.argv[1] == '-K': col = 't2.KEYWORDS' >if sys.argv[1] == '-C': col = 't3.name' >if sys.argv[1] == '-H': col = 't2.HOMEPAGE' >if sys.argv[1] == '-L': col = 't2.LICENSE' >if sys.argv[1] == '-U': col = 't2.IUSE' >if sys.argv[1] == '-P': col = 't2.PROVIDE' >if sys.argv[1:][0][0] == '-': txt = ' '.join(sys.argv[2:]) >con = MySQLdb.connect(user='root'); cur = con.cursor(); cur.execute('use portage') >print 'Searching for : [%s]' % txt > >total = cur.execute('SELECT t1.name, t2.*, t3.name AS cat_name, t4.name AS path, t4.p_id FROM `package_name` AS t1, `items_table` as t2, `category_table` as t3, `path_table` as t4 WHERE %s LIKE "%%%s%%" AND (t1.data_id = t2.i_id AND t1.cat_id = t3.c_id AND t1.path_id = t4.p_id) LIMIT 0,1000' % (col, ex(txt))) >rows = [ row[0] for row in cur.description] ># .*-([.\d]).* >for item in cur.fetchall(): > pkg = dict(zip(rows, item)) > r = re_split('\.*-([.\d].*)', pkg['name']) > r[0] = pkg['cat_name'] + '/' + r[0] > uniq.setdefault(r[0], [r[1], pkg, []]) > if r[1] > uniq[r[0]][0]: > uniq[r[0]][0] = r[1] > uniq[r[0]][1] = pkg > if r[1] not in uniq[r[0]][2]: uniq[r[0]][2] += [r[1]] >for i in uniq: > pkg = uniq[i][1]; uniq[i][2].remove(uniq[i][0]) > print green("*"), blue(bold( i )) > print '\t', darkgreen('Version'), uniq[i][0] > if uniq[i][2]: print '\t', darkgreen('Available versions:'), uniq[i][2] > print '\t', darkgreen('Keywords:'), pkg['KEYWORDS'] > print '\t', darkgreen("Homepage:"), pkg['HOMEPAGE'] > print '\t', darkgreen("Description:"), pkg['DESCRIPTION'] > print '\t', darkgreen("Ebuild:"), pkg['path'].replace('/var/cache/edb/dep', '') + '/' + i + '/' + pkg['name'] + '.ebuild', '[%d]' % pkg['p_id'] > #print '\t', darkgreen('Source URL:'), pkg['SRC_URI'] > if pkg['IUSE'] : print '\t', darkgreen('IUSE:'), pkg['IUSE'] > if pkg['SLOT'] != '0': print '\t', darkgreen('SLOT:'), pkg['SLOT'] > if pkg['PROVIDE']: print '\t', darkgreen('Provides:'), pkg['PROVIDE'] > print '\t', darkgreen('Last Modified:'), datetime.fromtimestamp( float(pkg['_mtime_']) ).ctime() > print '\t', darkgreen("License:"), pkg['LICENSE'] > print >print 'Found %d packages, %d versions total' % ( len(uniq), total) > #pp.pprint(item)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 51704
:
31813
|
31814
|
31815
|
32679
|
32680
|
37914
| 37916