From: Ian Jackson Date: Fri, 18 Oct 2019 20:31:13 +0000 (+0100) Subject: make-secnet-sites: Fix calls to string.split and sring.join X-Git-Tag: v0.5.0~34 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=commitdiff_plain;h=7a743f6a0571fb899e661cf492d635ad27159e6f make-secnet-sites: Fix calls to string.split and sring.join These go away in python3. They want us to use this daft objecty syntax instead. Signed-off-by: Ian Jackson --- diff --git a/make-secnet-sites b/make-secnet-sites index 395066e..3264adf 100755 --- a/make-secnet-sites +++ b/make-secnet-sites @@ -98,7 +98,7 @@ else: sys.exit(1) ugs=os.environ["USERV_GROUP"] ok=0 - for i in string.split(ugs): + for i in ugs.split(): if group==i: ok=1 if not ok: print("caller not in group %s"%group) @@ -299,7 +299,7 @@ class vpnlevel(level): w.write("\n") self.indent(w,ind+2) w.write("all-sites %s;\n"% - string.join(self.children.keys(),',')) + ','.join(self.children.keys())) self.indent(w,ind) w.write("};\n") @@ -319,9 +319,9 @@ class locationlevel(level): self.indent(w,ind) # The "h=h,self=self" abomination below exists because # Python didn't support nested_scopes until version 2.1 - w.write("%s %s;\n"%(self.name,string.join( + w.write("%s %s;\n"%(self.name,','.join( map(lambda x,h=h,self=self: - h+"/"+x,self.children.keys()),','))) + h+"/"+x,self.children.keys())))) class sitelevel(level): "Site level (i.e. a leafnode) in the configuration hierarchy" @@ -398,7 +398,7 @@ def set_property(obj,w): def pline(i,allow_include=False): "Process a configuration file line" global allow_defs, obstack, root - w=string.split(i.rstrip('\n')) + w=i.rstrip('\n').split() if len(w)==0: return [i] keyword=w[0] current=obstack[len(obstack)-1] @@ -482,7 +482,7 @@ def outputsites(w): w.write("# secnet sites file autogenerated by make-secnet-sites " +"version %s\n"%VERSION) w.write("# %s\n"%time.asctime(time.localtime(time.time()))) - w.write("# Command line: %s\n\n"%string.join(sys.argv)) + w.write("# Command line: %s\n\n"%' '.join(sys.argv)) # Raw VPN data section of file w.write(prefix+"vpn-data {\n") @@ -497,9 +497,9 @@ def outputsites(w): w.write("};\n") # Flattened list of sites - w.write(prefix+"all-sites %s;\n"%string.join( + w.write(prefix+"all-sites %s;\n"%",".join( map(lambda x:"%svpn/%s/all-sites"%(prefix,x), - root.children.keys()),",")) + root.children.keys()))) line=0 file=None