feat: adds consume.sections
This commit is contained in:
parent
d35d0df021
commit
70661d39b8
1 changed files with 24 additions and 1 deletions
|
|
@ -49,6 +49,26 @@ class consume:
|
||||||
current = ""
|
current = ""
|
||||||
return pars
|
return pars
|
||||||
|
|
||||||
|
class sections(Consume):
|
||||||
|
def __init__(self, mark = r"^#", skip = "False"):
|
||||||
|
self.mark = mark
|
||||||
|
self.skip = bool(skip)
|
||||||
|
|
||||||
|
def __call__(self, stream):
|
||||||
|
sec = []
|
||||||
|
current = ""
|
||||||
|
for item in stream.readlines():
|
||||||
|
if re.match(self.mark, item[0]):
|
||||||
|
sec.append( current )
|
||||||
|
if self.skip:
|
||||||
|
current = ""
|
||||||
|
else:
|
||||||
|
current = item
|
||||||
|
else:
|
||||||
|
current += item
|
||||||
|
sec.append( current )
|
||||||
|
return sec
|
||||||
|
|
||||||
class format:
|
class format:
|
||||||
class Format:
|
class Format:
|
||||||
def __call__(self, items):
|
def __call__(self, items):
|
||||||
|
|
@ -317,8 +337,11 @@ def main():
|
||||||
asked.lift = ["stdout"]
|
asked.lift = ["stdout"]
|
||||||
|
|
||||||
logger.debug("Chosen operators:")
|
logger.debug("Chosen operators:")
|
||||||
|
|
||||||
|
cop,cargs = list(operator([asked.consume]))[0]
|
||||||
|
|
||||||
forthlift = Forthlifter(
|
forthlift = Forthlifter(
|
||||||
consumer = consumers[asked.consume](),
|
consumer = consumers[cop](*cargs),
|
||||||
streamers = [streamers[op](*args) for op,args in operator(asked.stream)],
|
streamers = [streamers[op](*args) for op,args in operator(asked.stream)],
|
||||||
formatters = [formaters[op](*args) for op,args in operator(asked.format)],
|
formatters = [formaters[op](*args) for op,args in operator(asked.format)],
|
||||||
lifters = [ lifters[op](*args) for op,args in operator(asked.lift )],
|
lifters = [ lifters[op](*args) for op,args in operator(asked.lift )],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue