Use str.find(), not str.index() in each_message
This commit is contained in:
parent
3e7fea6c11
commit
47c70385aa
1 changed files with 9 additions and 9 deletions
|
@ -26,19 +26,19 @@ def each_line(text: str):
|
||||||
end = len(text)
|
end = len(text)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
index = text.find('\n', start, end)
|
||||||
index = text.index('\n', start, end)
|
|
||||||
|
|
||||||
yield text[start:index+1]
|
if index < 0:
|
||||||
|
|
||||||
start = index + 1
|
|
||||||
|
|
||||||
if start == end:
|
|
||||||
break
|
|
||||||
except ValueError:
|
|
||||||
yield text[start:end]
|
yield text[start:end]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
yield text[start:index+1]
|
||||||
|
|
||||||
|
start = index + 1
|
||||||
|
|
||||||
|
if start == end:
|
||||||
|
break
|
||||||
|
|
||||||
def parse_timestamp(timestamp: str):
|
def parse_timestamp(timestamp: str):
|
||||||
if timestamp is None or timestamp == '':
|
if timestamp is None or timestamp == '':
|
||||||
return datetime.datetime.fromtimestamp(0)
|
return datetime.datetime.fromtimestamp(0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue