chiark / gitweb /
make-secnet-sites: Replace string.atol with int()
[secnet.git] / make-secnet-sites
index 395066e8b5f2f07eaf6cc4e5a668d804b8d2a993..f32267824cbd954177416cb9bcfac3c9582e73f6 100755 (executable)
@@ -52,6 +52,7 @@ Cendio Systems AB.
 """
 
 from __future__ import print_function
+from builtins import int
 
 import string
 import time
@@ -98,7 +99,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)
@@ -191,7 +192,7 @@ class boolean (basetype):
 class num (basetype):
        "A decimal number"
        def __init__(self,w):
-               self.n=string.atol(w[1])
+               self.n=int(w[1])
        def __str__(self):
                return '%d'%(self.n)
 
@@ -199,7 +200,7 @@ class address (basetype):
        "A DNS name and UDP port number"
        def __init__(self,w):
                self.adr=w[1]
-               self.port=string.atoi(w[2])
+               self.port=int(w[2])
                if (self.port<1 or self.port>65535):
                        complain("invalid port number")
        def __str__(self):
@@ -208,7 +209,7 @@ class address (basetype):
 class rsakey (basetype):
        "An RSA public key"
        def __init__(self,w):
-               self.l=string.atoi(w[1])
+               self.l=int(w[1])
                self.e=w[2]
                self.n=w[3]
        def __str__(self):
@@ -299,7 +300,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 +320,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 +399,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 +483,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 +498,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