diff --git a/lib/nntp/tiny/message.py b/lib/nntp/tiny/message.py index 6d8fe69..0cb32fc 100644 --- a/lib/nntp/tiny/message.py +++ b/lib/nntp/tiny/message.py @@ -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)