From cee774196ddee7c77a6f3d0bdbc530cb21629e13 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Fri, 3 Jan 2020 15:24:12 -0600 Subject: [PATCH] id-other-than: accommodate python 3 Signed-off-by: Rob Browning Tested-by: Rob Browning --- t/id-other-than | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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() -- 2.39.2