aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2010-11-17 19:48:31 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2010-11-17 19:48:31 +0000
commitac25b792f149a07350fa225d07834980b8c4262f (patch)
treea99a16e65a1a8c62321470fa7398b4c491e4373b
parentNew nocolor support for earch. (diff)
downloadrbot-gentoo-ac25b792f149a07350fa225d07834980b8c4262f.tar.gz
rbot-gentoo-ac25b792f149a07350fa225d07834980b8c4262f.tar.bz2
rbot-gentoo-ac25b792f149a07350fa225d07834980b8c4262f.zip
Bump earch to support newer Portage 2.2.
-rwxr-xr-x[-rw-r--r--]gentoo-scripts/earch66
1 files changed, 46 insertions, 20 deletions
diff --git a/gentoo-scripts/earch b/gentoo-scripts/earch
index 7d72dd2..de9f7bd 100644..100755
--- a/gentoo-scripts/earch
+++ b/gentoo-scripts/earch
@@ -3,10 +3,13 @@
# $Header: $
# Authors:
# Eldad Zack <eldad@gentoo.org> - Original application
-# Robin H. Johnson <robbat2@gentoo.org> - SLOT and masking support
+# Robin H. Johnson <robbat2@gentoo.org> - SLOT and masking support, and many
+# other improvements.
+#
+# Present Maintainer: robbat2@gentoo.org
#
# earch: Gentoo last arch keyword checking tool, with SLOT and masking support
-# version 0.9.2
+# version 0.9.5
import sys
import os
@@ -34,13 +37,16 @@ def earch_main():
opt_ignore_redundant = False
opt_follow_etc_portage = False
opt_version = False
+ opt_quiet = False
opt_slot = []
# process commandline
try:
- (opts,args) = getopt.gnu_getopt(sys.argv[1:],'CcfhHims:orv',['nocolor','category','masking-reasons','help','hide-masked','version','slot=','remove-pkgs','ignore-redundant','follow-etc-portage'])
+ (opts,args) = getopt.gnu_getopt(sys.argv[1:],'CcfhHims:orv',['nocolor','quiet','category','masking-reasons','help','hide-masked','version','slot=','remove-pkgs','ignore-redundant','follow-etc-portage'])
for optkey,optvalue in opts:
if optkey == '--nocolor':
opt_nocolor = True
+ if optkey == '--quiet':
+ opt_quiet = True
if optkey == '-c' or optkey == '--category':
opt_category = True
if optkey == '-f' or optkey == '--follow-etc-portage':
@@ -82,7 +88,7 @@ def earch_main():
os.environ["PORTAGE_CALLER"]="repoman"
# generate
- (ebuildlist,ebuilddata,pkgkeywords) = earch_data_generate(args,slots=opt_slot,hide_masked=opt_hide_masked,include_category=opt_category,ignore_redundant=opt_ignore_redundant,one_slot=opt_one_slot,nocolor=opt_nocolor)
+ (ebuildlist,ebuilddata,pkgkeywords) = earch_data_generate(args,slots=opt_slot,hide_masked=opt_hide_masked,include_category=opt_category,ignore_redundant=opt_ignore_redundant,one_slot=opt_one_slot,nocolor=opt_nocolor,quiet=opt_quiet)
if opt_remove_pkgs:
earch_remove_pkgs(ebuildlist,ebuilddata,pkgkeywords)
@@ -134,6 +140,12 @@ def earch_help():
print '-s|--slot <SLOT,...>'
print ' SLOT values to provide output for, seperated by commas.'
print
+ print '--nocolor'
+ print ' Disable ANSI color output'
+ print
+ print '--quiet'
+ print ' Squelch Portage python warnings'
+ print
print '-v|--version'
print ' earch version output.'
print
@@ -151,21 +163,27 @@ def earch_manual_getkeywords(pkg):
file.close
return re.split(" ",keywords)
-def earch_data_generate(args,slots=[],hide_masked=False,include_category=False,ignore_redundant=False,one_slot=False,nocolor=False):
+def earch_data_generate(args,slots=[],hide_masked=False,include_category=False,ignore_redundant=False,one_slot=False,nocolor=False,quiet=False):
+ # This makes portage really quiet
stderr = sys.stderr
- sys.stderr = open('/dev/null', 'w')
+ if quiet:
+ sys.stderr = open('/dev/null', 'w')
import portage
# and reset it
sys.stderr = stderr
-
+
# disable color as needed
# this is actually out of place, but still the best place to run it
# to avoid importing portage twice
- if (not sys.stdout.isatty()) or (portage.settings["NOCOLOR"] in ["yes","true","1"] or nocolor):
- nocolor()
+ if nocolor:
+ portage.settings.unlock()
+ portage.settings["NOCOLOR"] = '1'
+ portage.settings.lock()
+ if (not sys.stdout.isatty()) or (portage.settings["NOCOLOR"] in ["yes","true","1"]):
+ portage.output.nocolor()
portdir = portage.settings["PORTDIR"]
- portdb = portage.portdbapi(portdir)
+ portdb = portage.portdbapi(None, portage.settings)
archslotdict = {}
ebuildlist = []
ebuilddata = {}
@@ -291,16 +309,24 @@ def earch_data_generate(args,slots=[],hide_masked=False,include_category=False,i
pk = pkgkeywords[pkg]
npk = pk
rk = ebuilddata[pkg]['RAW_KEYWORDS']
- def earch_sort_cmp(x,y,src=rk):
- ix = src.index(x)
- iy = src.index(y)
- if(ix > iy):
- return 1
- elif(ix < iy):
- return -1
- else:
- return 0
- npk.sort(cmp=earch_sort_cmp)
+ if rk is not None:
+ def earch_sort_cmp(x,y,src=rk):
+ if x is None and y is None:
+ return 0
+ elif x is None and y is not None:
+ return 1
+ elif x is not None and y is None:
+ return -1
+ # nobody is None
+ ix = src.index(x)
+ iy = src.index(y)
+ if(ix > iy):
+ return 1
+ elif(ix < iy):
+ return -1
+ else:
+ return 0
+ npk.sort(cmp=earch_sort_cmp)
pkgkeywords[pkg] = npk
return (ebuildlist,ebuilddata,pkgkeywords)