Skip to content

Commit c494439

Browse files
committed
Fixed incorrect error for characters that do not exist
1 parent 472ed5c commit c494439

File tree

5 files changed

+20
-23
lines changed

5 files changed

+20
-23
lines changed

.run/Unittests.run.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
<module name="tibia.py" />
44
<option name="INTERPRETER_OPTIONS" value="" />
55
<option name="PARENT_ENVS" value="true" />
6-
<option name="SDK_HOME" value="$PROJECT_DIR$/venv/bin/python" />
7-
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
8-
<option name="IS_MODULE_SDK" value="false" />
6+
<option name="SDK_HOME" value="" />
7+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests" />
8+
<option name="IS_MODULE_SDK" value="true" />
99
<option name="ADD_CONTENT_ROOTS" value="true" />
1010
<option name="ADD_SOURCE_ROOTS" value="true" />
1111
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
1212
<option name="_new_pattern" value="&quot;&quot;" />
1313
<option name="_new_additionalArguments" value="&quot;&quot;" />
14-
<option name="_new_target" value="&quot;tibiapy&quot;" />
15-
<option name="_new_targetType" value="&quot;CUSTOM&quot;" />
14+
<option name="_new_target" value="&quot;$PROJECT_DIR$/tests&quot;" />
15+
<option name="_new_targetType" value="&quot;PATH&quot;" />
1616
<method v="2" />
1717
</configuration>
1818
</component>

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+
.. v4.1.5
10+
11+
4.1.5 (2021-06-25)
12+
==================
13+
- Fixed parsing bug on characters, returning an incorrect exception when a character doesn't exist.
14+
15+
916
.. v4.1.4
1017
1118
4.1.4 (2021-06-17)
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
<div class="BoxContent" style="background-image:url(https://ssl-static-tibia.akamaized.net/images/global/content/scroll.gif);">
2-
<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
3-
<TR><TD BGCOLOR="#505050" CLASS=white><B>Could not find character</B></TD></TR>
4-
<TR><TD BGCOLOR="#D4C0A1"><TABLE BORDER=0 CELLPADDING=1><TR><TD>Character <b>afasfagf</b> does not exist.</TD></TR></TABLE></TD></TR>
5-
</TABLE>
6-
<br /><br /> <FORM ACTION="https://www.tibia.com/community/?subtopic=characters" METHOD=post>
7-
<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
8-
<TR><TD BGCOLOR="#505050" CLASS=white><B>Search Character</B></TD></TR>
9-
<TR><TD BGCOLOR="#D4C0A1"><TABLE BORDER=0 CELLPADDING=1><TR>
10-
<TD>Name:</TD><TD><INPUT NAME="name" VALUE="afasfagf"SIZE=29 MAXLENGTH=29></TD>
11-
<TD><INPUT TYPE=image NAME="Submit" SRC="https://ssl-static-tibia.akamaized.net/images/global/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></TD>
12-
</TR></TABLE></TD></TR>
13-
</TABLE>
14-
</FORM>
15-
</div>
1+
<div class="BoxContent" style="background-image:url(https://static.tibia.com/images/global/content/scroll.gif);">
2+
<div class="TableContainer"> <table class="Table1" cellpadding="0" cellspacing="0"> <div class="CaptionContainer"> <div class="CaptionInnerContainer"> <span class="CaptionEdgeLeftTop" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-edge.gif);" /></span> <span class="CaptionEdgeRightTop" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-edge.gif);" /></span> <span class="CaptionBorderTop" style="background-image:url(https://static.tibia.com/images/global/content/table-headline-border.gif);"></span> <span class="CaptionVerticalLeft" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-vertical.gif);" /></span> <div class="Text">Could not find character</div> <span class="CaptionVerticalRight" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-vertical.gif);" /></span> <span class="CaptionBorderBottom" style="background-image:url(https://static.tibia.com/images/global/content/table-headline-border.gif);"></span> <span class="CaptionEdgeLeftBottom" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-edge.gif);" /></span> <span class="CaptionEdgeRightBottom" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-edge.gif);" /></span> </div> </div> <tr> <td> <div class="InnerTableContainer"> <table style="width:100%;"><tr><td>Character <b>critosio</b> does not exist.</td></tr> </table> </div> </td> </tr> </table></div><br /><br /><form><div class="TableContainer"> <table class="Table1" cellpadding="0" cellspacing="0"> <div class="CaptionContainer"> <div class="CaptionInnerContainer"> <span class="CaptionEdgeLeftTop" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-edge.gif);" /></span> <span class="CaptionEdgeRightTop" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-edge.gif);" /></span> <span class="CaptionBorderTop" style="background-image:url(https://static.tibia.com/images/global/content/table-headline-border.gif);"></span> <span class="CaptionVerticalLeft" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-vertical.gif);" /></span> <div class="Text">Search Character</div> <span class="CaptionVerticalRight" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-vertical.gif);" /></span> <span class="CaptionBorderBottom" style="background-image:url(https://static.tibia.com/images/global/content/table-headline-border.gif);"></span> <span class="CaptionEdgeLeftBottom" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-edge.gif);" /></span> <span class="CaptionEdgeRightBottom" style="background-image:url(https://static.tibia.com/images/global/content/box-frame-edge.gif);" /></span> </div> </div> <tr> <td> <div class="InnerTableContainer"> <table style="width:100%;"><tr><td style="vertical-align:middle;" class="LabelV150">Character Name:</td><td style="width:170px;"><input style="width:165px;" name="name" value="critosio" size="29" maxlength="29" /></td><td><div class="BigButton" style="background-image:url(https://static.tibia.com/images/global/buttons/button_blue.gif)"><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);"><div class="BigButtonOver" style="background-image:url(https://static.tibia.com/images/global/buttons/button_blue_over.gif);"></div><input class="BigButtonText" type="submit" value="Submit" /></div></div></td></tr> </table> </div> </td> </tr> </table></div></form> </div>
3+
</div>

tibiapy/__init__.py

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

44
import logging

tibiapy/character.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,10 @@ def from_content(cls, content):
309309
parsed_content = parse_tibiacom_content(content)
310310
tables = cls._parse_tables(parsed_content)
311311
char = Character()
312-
if "Could not find character" in tables.keys():
313-
return None
312+
if not tables:
313+
messsage_table = parsed_content.find("div", {"class": "TableContainer"})
314+
if messsage_table and "Could not find character" in messsage_table.text:
315+
return None
314316
if "Character Information" in tables.keys():
315317
char._parse_character_information(tables["Character Information"])
316318
else:

0 commit comments

Comments
 (0)