Deligate processing extra chat data to Block class
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from . import parser
|
||||
class Block:
|
||||
"""Block object represents virtual chunk of chatdata.
|
||||
|
||||
@@ -33,4 +34,23 @@ class Block:
|
||||
self.last = last
|
||||
self.temp_last = 0
|
||||
self.continuation = continuation
|
||||
self.chat_data = chat_data
|
||||
self.chat_data = chat_data
|
||||
|
||||
def start(self):
|
||||
chats, cont = self._cut(self.chat_data, self.continuation, self.last)
|
||||
self.chat_data = chats
|
||||
return cont
|
||||
|
||||
def fill(self, chats, cont, fetched_last):
|
||||
chats, cont = self._cut(chats, cont, fetched_last)
|
||||
self.chat_data.extend(chats)
|
||||
return cont
|
||||
|
||||
def _cut(self, chats, cont, fetched_last):
|
||||
if fetched_last < self.temp_last or self.temp_last == -1:
|
||||
return chats, cont
|
||||
for i, line in enumerate(chats):
|
||||
line_offset = parser.get_offset(line)
|
||||
if line_offset >= self.temp_last:
|
||||
self.last = line_offset
|
||||
return chats[:i], None
|
||||
|
||||
Reference in New Issue
Block a user