chiark / gitweb /
make-secnet-sites: Provide base91s_encode and base91s_decode
[secnet.git] / make-secnet-sites
index ceb708f0dc143edb0198529ce9210252c7d87d5b..6cb131e126689130a755ac67421a4f4f875fd1e9 100755 (executable)
@@ -70,6 +70,7 @@ import ipaddress
 sys.path.insert(1,"/usr/local/share/secnet")
 sys.path.insert(1,"/usr/share/secnet")
 import ipaddrset
+import base91
 
 from argparseactionnoyes import ActionNoYes
 
@@ -89,6 +90,12 @@ def debugrepr(*args):
        if debug_level > 0:
                print(repr(args), file=sys.stderr)
 
+def base91s_encode(bindata):
+       return base91.encode(bindata).replace('"',"-")
+
+def base91s_decode(string):
+       return base91.decode(string.replace("-",'"'))
+
 class Tainted:
        def __init__(self,s,tline=None,tfile=None):
                self._s=s
@@ -605,9 +612,9 @@ def pline(il,filterstate,allow_include=False):
        w=list([Tainted(x) for x in w])
        keyword=w[0]
        current=obstack[len(obstack)-1]
-       copyout=lambda: ['    '*len(obstack) +
-                       ' '.join([ww.output() for ww in w]) +
-                       '\n']
+       copyout_core=lambda: ' '.join([ww.output() for ww in w])
+       indent='    '*len(obstack)
+       copyout=lambda: [indent + copyout_core() + '\n']
        if keyword=='end-definitions':
                keyword.raw_mark_ok()
                allow_defs=sitelevel.depth