From: Ian Jackson Date: Fri, 29 Nov 2019 20:05:21 +0000 (+0000) Subject: make-secnet-sites: Introduce FilterState X-Git-Tag: v0.6.0~109 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=commitdiff_plain;h=af213e94bef4bae0e84be3b0092d5109515f4e34 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 --- 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):