From 9d0b8b6ffffac1b46faf56976f680febe2fcee9c Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 1 Nov 2021 15:38:03 +0100 Subject: [PATCH] cleanup --- logFileModel.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/logFileModel.py b/logFileModel.py index 5ed6248..9d2dfaf 100644 --- a/logFileModel.py +++ b/logFileModel.py @@ -1,7 +1,5 @@ import math import re -import threading -import time from typing import List, Optional from PyQt6.QtCore import pyqtSignal @@ -79,15 +77,15 @@ class LogFileModel: def read_word_at(self, byte_offset: int) -> (str, int, int): lines = self.data(byte_offset, 0, 1) if len(lines) == 0: - return ("", -1, -1) + return "", -1, -1 line: Line = lines[0] if not lines[0].includes_byte(byte_offset): - return ("", -1, -1) + return "", -1, -1 offset_in_line = byte_offset - line.byte_offset() current_char = line.line()[line.byte_index_to_char_index(offset_in_line)] if not self._is_word_char(current_char): - return (current_char, byte_offset, byte_offset + 1) + return current_char, byte_offset, byte_offset + 1 start_in_line = line.byte_index_to_char_index(byte_offset - line.byte_offset()) while start_in_line - 1 >= 0 and self._is_word_char(line.line()[start_in_line - 1]): start_in_line = start_in_line - 1 @@ -96,7 +94,7 @@ class LogFileModel: end_in_line = end_in_line + 1 start_byte = line.char_index_to_byte(start_in_line) + line.byte_offset() end_byte = line.char_index_to_byte(end_in_line) + line.byte_offset() - return (line.line()[start_in_line:end_in_line], start_byte, end_byte) + return line.line()[start_in_line:end_in_line], start_byte, end_byte def _is_word_char(self, char: str) -> bool: return re.match(r"\w", char) is not None