feat: adds consume.nlines
This commit is contained in:
parent
70661d39b8
commit
77bd035f72
1 changed files with 21 additions and 0 deletions
|
|
@ -69,6 +69,27 @@ class consume:
|
|||
sec.append( current )
|
||||
return sec
|
||||
|
||||
class nlines(Consume):
|
||||
def __init__(self, nb = "10"):
|
||||
self.nb = int(nb)
|
||||
|
||||
def __call__(self, stream):
|
||||
sec = []
|
||||
count = 0
|
||||
current = ""
|
||||
for item in stream.readlines():
|
||||
if count >= self.nb:
|
||||
sec.append( current )
|
||||
current = ""
|
||||
count = 0
|
||||
else:
|
||||
current += item
|
||||
count += 1
|
||||
sec.append( current )
|
||||
return sec
|
||||
|
||||
|
||||
|
||||
class format:
|
||||
class Format:
|
||||
def __call__(self, items):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue