From 99c6664dab77fe663b81941c84b5aa0ff24ea761 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 29 Nov 2019 20:05:21 +0000 Subject: [PATCH] make-secnet-sites: Introduce FilterState This is going to let us be more stateful as we copy lines from the input to an output sites file, and as we process public keys into output secnet.conf files. No functional change yet. Signed-off-by: Ian Jackson --- make-secnet-sites | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/make-secnet-sites b/make-secnet-sites index d1c174c..ceb708f 100755 --- a/make-secnet-sites +++ b/make-secnet-sites @@ -589,8 +589,15 @@ def set_property(obj,w): else: obj.properties[propname]=kw[0](w) - -def pline(il,allow_include=False): +class FilterState: + def __init__(self): + self.reset() + def reset(self): + # called when we enter a new node, + # in particular, at the start of each site + pass + +def pline(il,filterstate,allow_include=False): "Process a configuration file line" global allow_defs, obstack, root w=il.rstrip('\n').split() @@ -647,6 +654,7 @@ def pline(il,allow_include=False): sys.exit(1) current.children[tname]=nl current=nl + filterstate.reset() obstack.append(current) return copyout() if keyword.raw() not in current.allow_properties: @@ -674,10 +682,11 @@ def pfile(name,lines,allow_include=False): file=name line=0 outlines=[] + filterstate = FilterState() for i in lines: line=line+1 if (i[0]=='#'): continue - outlines += pline(i,allow_include=allow_include) + outlines += pline(i,filterstate,allow_include=allow_include) return outlines def outputsites(w): -- 2.30.2