From: Brian Dolbec Date: Sun, 24 Apr 2011 00:59:32 +0000 (-0700) Subject: fix python-3 compatibility for euse bug 364081 X-Git-Tag: gentoolkit-0.3.0.1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=38d480d4eea1d2db421d4fa9ed9af2a32bbebe37;p=gentoolkit.git fix python-3 compatibility for euse bug 364081 --- diff --git a/bin/euse b/bin/euse index 8262271..5590fbb 100755 --- a/bin/euse +++ b/bin/euse @@ -185,7 +185,7 @@ VER # worth another look to avoid calling python unnecessariy. Or we could # just write the whole thing in python. ;) reduce_incrementals() { - echo $@ | python -c "import sys + echo $@ | python -c "from __future__ import print_function;import sys r=[] for x in sys.stdin.read().split(): if x[0] == '-' and x[1:] in r: @@ -196,14 +196,14 @@ for x in sys.stdin.read().split(): r.append(x) elif x == '-*': r = ['-*'] elif x not in r: r.append(x) -print ' '.join(r)" +print(' '.join(r))" } # }}} # Function: reduce_incrementals_trump {{{ # Similar to reduce_incrementals but negative flags trump positive # flags, regardless of which follows which reduce_incrementals_trump() { - echo $@ | python -c "import sys + echo $@ | python -c "from __future__ import print_function;import sys r=[] for x in sys.stdin.read().split(): if x[0] == '-' and x[1:] in r: @@ -211,7 +211,7 @@ for x in sys.stdin.read().split(): r.append(x) elif x == '-*': r = ['-*'] elif x not in r and not '-'+x in r: r.append(x) -print ' '.join(r)" +print(' '.join(r))" } # }}} # Function: reduce_package_use {{{ @@ -222,7 +222,7 @@ print ' '.join(r)" # * - Lines of package atom followed by flags # (app-editors/vim flag1 flag2 -flag3) reduce_package_use() { - echo "${@}" | python -c "import sys,re + echo "${@}" | python -c "from __future__ import print_function;import sys,re h={}; getflags=re.compile(r'(-?[\w*-]+)') for x in sys.stdin.read().split('\n'): if not x: continue @@ -242,7 +242,7 @@ for x in sys.stdin.read().split('\n'): elif x == '-*': r = h[pkg] = ['-*'] elif x not in r: r.append(x) -print '\n'.join(['%s %s' % (pkg,' '.join(flgs)) for pkg,flgs in h.iteritems() if len(flgs)])" +print('\n'.join(['%s %s' % (pkg,' '.join(flgs)) for pkg,flgs in h.items() if len(flgs)]))" } # }}} # Function: get_useflags {{{ @@ -511,8 +511,8 @@ get_flagstatus_helper_pkg() { if [[ -z "${atoms[@]/[<>=]*/}" ]]; then atoms=($( echo "${atoms[@]}" | python -c " -import portage.dep as dep, sys -print ' '.join(dep.match_to_list('$5-$6',sys.stdin.read().split()))")) +from __future__ import print_function;import portage.dep as dep, sys +print(' '.join(dep.match_to_list('$5-$6',sys.stdin.read().split()))")) fi flags=$(for atom in ${atoms[@]}; do [[ -z $atom ]] && continue