Skip to content

Commit 0cf419b

Browse files
authored
fix: keep mounts without a taming method (#12)
Articles without an `implemented` field now get `version` as `NULL` instead of being dropped, and mounts without a `taming_method` get it as `NULL` too. That is how Landsailer went missing from the index. A misspelled `implementation` field is not read, as the wiki does not show it. changes: - `version()` returns `None` when `implemented` is absent - `mount.taming_method` is optional - added Landsailer's wikitext (revision 1199522) as a test fixture Parsing all 18,378 articles from one snapshot with main and with this branch recovers Landsailer and adds no new failures.
2 parents 70b5226 + 4f8152d commit 0cf419b

7 files changed

Lines changed: 77 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<!-- Changed by tibia.sh in 2026. See "About this copy" in README.md. -->
22
# Changelog
33

4+
## Unreleased
5+
6+
- Store `version` as `NULL` in `game_update`, `house`, `outfit` and `mount` when an article has no `implemented`
7+
field, instead of dropping the article. A misspelled field like `implementation` is not read, as the wiki does not
8+
show it.
9+
- Store `mount.taming_method` as `NULL` when a mount's article has no `taming_method` field, instead of dropping the
10+
mount. Landsailer is now kept.
11+
412
## 9.0.0+tibiash.3
513

614
- Drop everything after an unclosed `<!--` in `creature.race_id`, `outfit.male_client_id`, `outfit.female_client_id`
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
3+
from tibiawikisql.parsers.base import AttributeParser
4+
5+
6+
class TestAttributeParserVersion(unittest.TestCase):
7+
def test_version_lowercases_implemented(self):
8+
self.assertEqual("pre-6.0", AttributeParser.version()({"implemented": "Pre-6.0"}))
9+
10+
def test_version_none_without_implemented(self):
11+
self.assertIsNone(AttributeParser.version()({}))
12+
13+
def test_version_ignores_implementation(self):
14+
self.assertIsNone(AttributeParser.version()({"implementation": "15.32"}))

‎tests/parsers/test_mount.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,30 @@ def test_mount_client_id_none_when_only_a_comment(self):
4848
mount = self._parse(self._edited("| mount_id\t= 644", "| mount_id\t= <!-- objectID: 51952-->"))
4949

5050
self.assertIsNone(mount.client_id)
51+
52+
53+
class TestMountParserMissingFields(unittest.TestCase):
54+
def _parse(self, title: str, resource: str) -> Mount:
55+
article = Article(
56+
article_id=1,
57+
title=title,
58+
timestamp=datetime.datetime.fromisoformat("2026-08-06T21:35:46+00:00"),
59+
content=load_resource(resource),
60+
)
61+
62+
return MountParser.from_article(article)
63+
64+
def test_mount_without_taming_method_or_version(self):
65+
mount = self._parse("Landsailer", "content_mount_landsailer.txt")
66+
67+
self.assertIsNone(mount.taming_method)
68+
self.assertIsNone(mount.version)
69+
self.assertEqual(10, mount.speed)
70+
self.assertEqual(140, mount.price)
71+
self.assertIsNone(mount.client_id)
72+
73+
def test_mount_with_taming_method_and_version(self):
74+
mount = self._parse("Doombringer", "content_mount.txt")
75+
76+
self.assertEqual("Buying it on Tibia.com or via the Store.", mount.taming_method)
77+
self.assertEqual("10.56", mount.version)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{Infobox Mount
2+
| name = Landsailer
3+
| image =
4+
| speed = 10
5+
| achievement =
6+
| premium = yes
7+
| colourisable = yes
8+
| bought = no
9+
| price = 140
10+
| pricecurrency = Event Points
11+
| event = The Great Expedition
12+
| implementation = 15.32
13+
| notes = Obtained during the reward phase of The Great Expedition world quest for 140 Event Points.
14+
}}
15+
16+
The '''Landsailer''' is a mount that can be obtained as a reward from [[The Great Expedition]] world quest.
17+
18+
== Obtaining ==
19+
Players can purchase this mount from [[Proprietor Piers]] south of [[Fibula]] during the reward phase (August 12–18) for '''140 Event Points''', provided their server successfully completed the preparation phase.
20+
21+
== See Also ==
22+
* [[Mounts]]
23+
* [[The Great Expedition]]

‎tibiawikisql/models/mount.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Mount(WikiEntry, WithStatus, WithVersion, WithImage, RowModel, table=Mount
1212
"""The name of the mount."""
1313
speed: int
1414
"""The speed given by the mount."""
15-
taming_method: str
15+
taming_method: str | None = None
1616
"""A brief description on how the mount is obtained."""
1717
is_buyable: bool
1818
"""Whether the mount can be bought from the store or not."""

‎tibiawikisql/parsers/base.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Changed by tibia.sh in 2026. See "About this copy" in README.md.
12
from collections.abc import Callable
23
from typing import Any, ClassVar, Generic, TypeVar
34

@@ -100,10 +101,10 @@ def version(cls) -> Self:
100101
"""Create a parser for the commonly found "implemented" parameter.
101102
102103
Returns:
103-
An attribute parser for the implemented parameter.
104+
An attribute parser for the implemented parameter, lowercased, falling back to None if not found.
104105
105106
"""
106-
return cls(lambda x: x.get("implemented").lower())
107+
return cls.optional("implemented", str.lower)
107108

108109

109110
class ParserMeta(type):

‎tibiawikisql/parsers/mount.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class MountParser(BaseParser):
2929
attribute_map: ClassVar = {
3030
"name": AttributeParser.required("name", remove_mount),
3131
"speed": AttributeParser.required("speed", int),
32-
"taming_method": AttributeParser.required("taming_method", clean_links),
32+
"taming_method": AttributeParser.optional("taming_method", clean_links),
3333
"is_buyable": AttributeParser.optional("bought", parse_boolean, False),
3434
"price": AttributeParser.optional("price", parse_integer),
3535
"achievement": AttributeParser.optional("achievement"),

0 commit comments

Comments
 (0)