Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop string early on empty socket detection #171

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/lang/enUS/corrections.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"compare",
" cts ",
"dearest will",
"when equipped"
"when equipped",
"empty socket"
]
}
7 changes: 4 additions & 3 deletions src/item/descr/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ def find_number(s: str, idx: int = 0) -> float:


def remove_text_after_first_keyword(text: str, keywords: list[str]) -> str:
start_pos = None
for keyword in keywords:
match = re.search(re.escape(keyword), text)
start_pos = None
if match and (start_pos is None or start_pos > match.start()):
start_pos = match.start()
if start_pos is not None:
return text[:start_pos]
start_pos = match.start() if start_pos is None or start_pos > match.start() else start_pos
if start_pos is not None:
return text[:start_pos]
return text


Expand Down
Binary file added test/assets/item/read_descr_unique_1080p_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions test/item/read_descr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,17 @@
],
),
),
(
(1920, 1080),
f"{BASE_PATH}/read_descr_unique_1080p_3.png",
Item(
ItemRarity.Unique,
ItemType.ChestArmor,
804,
Aspect("razorplate", 11197),
[],
),
),
],
)
def test_read_descr(img_res: tuple[int, int], input_img: str, expected_item: Item):
Expand Down
Loading