From: Rob Browning Date: Fri, 3 Jan 2020 21:24:12 +0000 (-0600) Subject: id-other-than: accommodate python 3 X-Git-Tag: 0.31~116 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=cee774196ddee7c77a6f3d0bdbc530cb21629e13 id-other-than: accommodate python 3 Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/t/id-other-than b/t/id-other-than index eb6aead..9c240fa 100755 --- a/t/id-other-than +++ b/t/id-other-than @@ -5,14 +5,18 @@ exec "$bup_python" "$0" ${1+"$@"} """ # end of bup preamble -from __future__ import absolute_import +# Note: this currently relies on bup-python to handle arbitrary binary +# user/group names. + +from __future__ import absolute_import, print_function import grp import pwd import sys def usage(): - print >> sys.stderr, "Usage: id-other-than <--user|--group> ID [ID ...]" + print('Usage: id-other-than <--user|--group> ID [ID ...]', + file=sys.stderr) if len(sys.argv) < 2: usage() @@ -22,7 +26,7 @@ def is_integer(x): try: int(x) return True - except ValueError, e: + except ValueError as e: return False excluded_ids = set(int(x) for x in sys.argv[2:] if is_integer(x)) @@ -33,14 +37,14 @@ if sys.argv[1] == '--user': excluded_ids.add(pwd.getpwnam(x).pw_uid) for x in pwd.getpwall(): if x.pw_uid not in excluded_ids: - print x.pw_name + ':' + str(x.pw_uid) + print(x.pw_name + ':' + str(x.pw_uid)) sys.exit(0) elif sys.argv[1] == '--group': for x in excluded_names: excluded_ids.add(grp.getgrnam(x).gr_gid) for x in grp.getgrall(): if x.gr_gid not in excluded_ids: - print x.gr_name + ':' + str(x.gr_gid) + print(x.gr_name + ':' + str(x.gr_gid)) sys.exit(0) else: usage()