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)
|
||||
|
||||
while True:
|
||||
try:
|
||||
index = text.index('\n', start, end)
|
||||
index = text.find('\n', start, end)
|
||||
|
||||
yield text[start:index+1]
|
||||
|
||||
start = index + 1
|
||||
|
||||
if start == end:
|
||||
break
|
||||
except ValueError:
|
||||
if index < 0:
|
||||
yield text[start:end]
|
||||
break
|
||||
|
||||
yield text[start:index+1]
|
||||
|
||||
start = index + 1
|
||||
|
||||
if start == end:
|
||||
break
|
||||
|
||||
def parse_timestamp(timestamp: str):
|
||||
if timestamp is None or timestamp == '':
|
||||
return datetime.datetime.fromtimestamp(0)
|
||||
|
|
Loading…
Add table
Reference in a new issue