From 81a29dce18b7298c88635a2bfbee52fb16ded3b9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 16 Oct 2019 21:16:38 +0100 Subject: [PATCH] make-secnet-sites: Put parens around print() statements This is part of the transition to python3. In actual fact these are all error messages and should go to stderr but I'm ot fixing that right now. Signed-off-by: Ian Jackson --- ipaddrset-test.py | 36 +++++++++++++++++++----------------- make-secnet-sites | 20 +++++++++++--------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/ipaddrset-test.py b/ipaddrset-test.py index a60a5e8..7dff389 100755 --- a/ipaddrset-test.py +++ b/ipaddrset-test.py @@ -29,6 +29,8 @@ # The corresponding test vector file ise ipaddrset-test.expected. I # don't believe it is a creative work that attracts copyright. -iwj. +from __future__ import print_function + import ipaddr from ipaddr import IPNetwork, IPAddress @@ -38,33 +40,33 @@ from ipaddrset import IPAddressSet v4a=IPAddress('172.18.45.6') s=IPAddressSet() -print 's =', s +print('s =', s) s.append([IPNetwork('172.18.45.0/24')]) s.append([IPNetwork('2001:23:24::/48')]) -print s +print(s) t=IPAddressSet(map(IPNetwork,['172.31.80.8/32','172.18.45.192/28'])) -print 't =', t -print t <= s -print t == s +print('t =', t) +print(t <= s) +print(t == s) for n1s in ['172.18.44.0/23','172.18.45.6/32','172.18.45.0/24']: n1=IPNetwork(n1s) - print n1 - print s.contains(n1) - print t.contains(n1) + print(n1) + print(s.contains(n1)) + print(t.contains(n1)) n=s.networks()[0] a=ipaddrset.complete_set() -print 'a =', a -print a >= s -print a >= t +print('a =', a) +print(a >= s) +print(a >= t) -print '^' -print s.intersection(t) -print t.intersection(s) +print('^') +print(s.intersection(t)) +print(t.intersection(s)) -print 'u' -print s.union(t) -print t.union(s) +print('u') +print(s.union(t)) +print(t.union(s)) diff --git a/make-secnet-sites b/make-secnet-sites index 5162b54..d6f9ee0 100755 --- a/make-secnet-sites +++ b/make-secnet-sites @@ -51,6 +51,8 @@ Cendio Systems AB. """ +from __future__ import print_function + import string import time import sys @@ -77,7 +79,7 @@ if len(sys.argv)<2: else: if sys.argv[1]=='-u': if len(sys.argv)!=6: - print "Wrong number of arguments" + print("Wrong number of arguments") sys.exit(1) service=1 header=sys.argv[2] @@ -85,26 +87,26 @@ else: sitesfile=sys.argv[4] group=sys.argv[5] if not os.environ.has_key("USERV_USER"): - print "Environment variable USERV_USER not found" + print("Environment variable USERV_USER not found") sys.exit(1) user=os.environ["USERV_USER"] # Check that group is in USERV_GROUP if not os.environ.has_key("USERV_GROUP"): - print "Environment variable USERV_GROUP not found" + print("Environment variable USERV_GROUP not found") sys.exit(1) ugs=os.environ["USERV_GROUP"] ok=0 for i in string.split(ugs): if group==i: ok=1 if not ok: - print "caller not in group %s"%group + print("caller not in group %s"%group) sys.exit(1) else: if sys.argv[1]=='-P': prefix=sys.argv[2] sys.argv[1:3]=[] if len(sys.argv)>3: - print "Too many arguments" + print("Too many arguments") sys.exit(1) inputfile=sys.argv[1] of=sys.stdout @@ -371,12 +373,12 @@ reserved.update(levels) def complain(msg): "Complain about a particular input line" global complaints - print ("%s line %d: "%(file,line))+msg + print(("%s line %d: "%(file,line))+msg) complaints=complaints+1 def moan(msg): "Complain about something in general" global complaints - print msg; + print(msg); complaints=complaints+1 root=level(['root','root']) # All vpns are children of this node @@ -560,8 +562,8 @@ delempty(root) checkconstraints(root,{},ipaddrset.complete_set()) if complaints>0: - if complaints==1: print "There was 1 problem." - else: print "There were %d problems."%(complaints) + if complaints==1: print("There was 1 problem.") + else: print("There were %d problems."%(complaints)) sys.exit(1) if service: -- 2.30.2