Skip to content

Commit 9929cd6

Browse files
committed
Fixed parsing bug with guilds containing "of the"
1 parent c359bf8 commit 9929cd6

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ Changelog
66
Due to this library relying on external content, older versions are not guaranteed to work.
77
Try to always use the latest version.
88

9+
.. v3.6.1:
10+
11+
3.6.1 (2020-12-28)
12+
==================
13+
14+
- Fixed guild information being parsed incorrectly for characters in guilds containing "of the" in their name.
15+
916
.. v3.6.0:
1017
1118
3.6.0 (2020-12-12)

tibiapy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '3.6.0'
1+
__version__ = '3.6.1'
22
__author__ = 'Allan Galarza'
33

44
import logging

tibiapy/character.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
link_content = re.compile(r'>([^<]+)<')
2727

2828
house_regexp = re.compile(r'paid until (.*)')
29-
guild_regexp = re.compile(r'([\s\w()]+)\sof the\s(.+)')
3029

3130
title_regexp = re.compile(r'(.*)\((\d+) titles? unlocked\)')
3231
badge_popup_regexp = re.compile(r"\$\(this\),\s+'([^']+)',\s+'([^']+)',")
@@ -427,6 +426,12 @@ def _parse_character_information(self, rows):
427426
houses.append({"id": int(query["houseid"][0]), "name": house_link.text.strip(),
428427
"town": query["town"][0], "paid_until": paid_until_date})
429428
continue
429+
if field == "guild_membership":
430+
guild_link = cols_raw[1].find('a')
431+
rank = value.split("of the")[0]
432+
char["guild_membership"] = GuildMembership(guild_link.text, rank.strip())
433+
434+
continue
430435
if field in int_rows:
431436
value = int(value)
432437
char[field] = value
@@ -436,9 +441,6 @@ def _parse_character_information(self, rows):
436441
if m:
437442
char["name"] = m.group(1)
438443
char["deletion_date"] = parse_tibia_datetime(m.group(2))
439-
if "guild_membership" in char:
440-
m = guild_regexp.match(char["guild_membership"])
441-
char["guild_membership"] = GuildMembership(m.group(2), m.group(1))
442444

443445
if "(traded)" in char["name"]:
444446
char["name"] = char["name"].replace("(traded)","").strip()
@@ -682,6 +684,7 @@ class GuildMembership(abc.BaseGuild, abc.Serializable):
682684
The title of the member in the guild.
683685
"""
684686
__slots__ = (
687+
"name",
685688
"rank",
686689
"title",
687690
)

0 commit comments

Comments
 (0)