Skip to content

Commit 8568faa

Browse files
committed
Fix OCR validation
1 parent 0e6a682 commit 8568faa

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# The source skeleton for this configuration can be found at
55
# https://github.com/BesLogic/shared-configs/blob/main/ruff.toml
66
# Modifications to this file that are not project-specific should also be done upstream.
7-
# These configs are incompatible with ruff<0.5.7
87

98
# https://docs.astral.sh/ruff/configuration/
109
target-version = "py311" # Change this to the oldest supported version by your application
1110
line-length = 100
1211
preview = true
12+
required-version = ">=0.9.0" # Removed ISC compatibility warning
1313

1414
[format]
1515
docstring-code-format = true

src/AutoSplitImage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ def __parse_text_file(self, path: str):
141141
self.__ocr_comparison_methods = data.get("methods", [0])
142142
self.__fps_limit = data.get("fps_limit", 0)
143143

144-
if self.__validate_ocr():
144+
if not self.__validate_ocr():
145145
error_messages.wrong_ocr_values(path)
146146
return
147147

148148
def __validate_ocr(self):
149149
values = [*self.__rect, *self.__ocr_comparison_methods, self.__fps_limit]
150150
return (
151151
all(value >= 0 for value in values) # Check for invalid negative values
152-
and self.__rect[1] > self.__rect[0]
153-
and self.__rect[3] > self.__rect[2]
152+
and self.__rect[0] < self.__rect[1]
153+
and self.__rect[2] < self.__rect[3]
154154
)
155155

156156
def __read_image_bytes(self, path: str):

src/error_messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,6 @@ def tesseract_missing(ocr_split_file_path: str):
270270
def wrong_ocr_values(ocr_split_file_path: str):
271271
set_text_message(
272272
f"{ocr_split_file_path!r} has invalid values."
273-
+ "\nPlease make sure that `left < right` and `top < bottom`. "
273+
+ "\nPlease make sure that `left &lt; right` and `top &lt; bottom`. "
274274
+ "Also check for negative values in the 'methods' or 'fps_limit' settings"
275275
)

0 commit comments

Comments
 (0)