From 3c22b5915dae95a226d93c8ba2b1baad9e7fc603 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 3 Nov 2019 16:58:17 +0000 Subject: [PATCH] make-secnet-sites: output_data: Change recursive variables Pass a tuple path, of the objects. rather than the string so far and an indent value. This will make it easier to more complex things here. Signed-off-by: Ian Jackson --- make-secnet-sites | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/make-secnet-sites b/make-secnet-sites index f56ed3f..cd8f5db 100755 --- a/make-secnet-sites +++ b/make-secnet-sites @@ -414,13 +414,14 @@ class level: if self.allow_properties[i]: self.indent(w,ind) w.write("%s"%self.prop_out(i)) - def output_data(self,w,ind,np): + def output_data(self,w,path): + ind = 2*len(path) self.indent(w,ind) w.write("%s {\n"%(self.name)) self.output_props(w,ind+2) if self.depth==1: w.write("\n"); for c in self.children.values(): - c.output_data(w,ind+2,np+self.name+"/") + c.output_data(w,path+(c,)) self.indent(w,ind) w.write("};\n") @@ -498,11 +499,13 @@ class sitelevel(level): } def __init__(self,w): level.__init__(self,w) - def output_data(self,w,ind,np): + def output_data(self,w,path): + ind=2*len(path) + np='/'.join(map(lambda i: i.name, path)) self.indent(w,ind) w.write("%s {\n"%(self.name)) self.indent(w,ind+2) - w.write("name \"%s\";\n"%(np+self.name)) + w.write("name \"%s\";\n"%(np,)) self.output_props(w,ind+2) self.indent(w,ind+2) w.write("link netlink {\n"); @@ -655,7 +658,7 @@ def outputsites(w): # Raw VPN data section of file w.write(prefix+"vpn-data {\n") for i in root.children.values(): - i.output_data(w,2,"") + i.output_data(w,(i,)) w.write("};\n") # Per-VPN flattened lists -- 2.30.2