@@ -34,9 +34,9 @@ class Character(abc.Character):
34
34
The name of the character.
35
35
36
36
deletion_date: Optional[:class:`datetime.datetime`]
37
- The date where the character will be deleted.
37
+ The date where the character will be deleted if it is scheduled for deletion .
38
38
39
- former_names: :class:`list`
39
+ former_names: List[ :class:`str`]
40
40
Previous names of this character.
41
41
42
42
sex: :class:`str`
@@ -55,7 +55,7 @@ class Character(abc.Character):
55
55
The character's current world
56
56
57
57
former_world: Optional[:class:`str`]
58
- The previous world where the character was in.
58
+ The previous world where the character was in, in the last 6 months .
59
59
60
60
residence: :class:`str`
61
61
The current hometown of the character.
@@ -70,18 +70,18 @@ class Character(abc.Character):
70
70
The guild the character is a member of. The dictionary contains a key for the rank and a key for the name.
71
71
72
72
last_login: Optional[:class:`datetime.datetime`]
73
- The last time the character logged in.
73
+ The last time the character logged in. It will be None if the character has never logged in.
74
74
75
75
comment: Optional[:class:`str`]
76
76
The displayed comment.
77
77
78
78
account_status: :class:`str`
79
79
Whether the character's account is Premium or Free.
80
80
81
- achievements: :class:`list` of :class:` dict`
82
- The achievement chosen to be displayed.
81
+ achievements: List[ :class:`dict`]
82
+ The achievements chosen to be displayed.
83
83
84
- deaths: :class:`list` of :class:` Death`
84
+ deaths: List[ :class:`Death`]
85
85
The character's recent deaths.
86
86
87
87
account_information: :class:`dict`
@@ -128,6 +128,17 @@ def guild_rank(self):
128
128
129
129
@staticmethod
130
130
def _beautiful_soup (content ):
131
+ """
132
+ Parses HTML content into a BeautifulSoup object.
133
+ Parameters
134
+ ----------
135
+ content: :class:`str`
136
+ The HTML content.
137
+
138
+ Returns
139
+ -------
140
+ :class:`bs4.BeautifulSoup`: The parsed content.
141
+ """
131
142
return bs4 .BeautifulSoup (content , 'html.parser' , parse_only = bs4 .SoupStrainer ("div" , class_ = "BoxContent" ))
132
143
133
144
@staticmethod
@@ -143,6 +154,7 @@ def _parse(content):
143
154
Returns
144
155
-------
145
156
:class:`dict[str, Any]`
157
+ A dictionary containing all the character's information.
146
158
"""
147
159
parsed_content = Character ._beautiful_soup (content )
148
160
tables = Character ._parse_tables (parsed_content )
@@ -166,7 +178,7 @@ def _parse_account_information(char, rows):
166
178
----------
167
179
char: :class:`dict`[str,Any]
168
180
Dictionary where information will be stored.
169
- rows: :class:`List[ bs4.Tag]`
181
+ rows: List[ :class:`bs4.Tag`]
170
182
A list of all rows contained in the table.
171
183
"""
172
184
char ["account_information" ] = {}
@@ -187,7 +199,7 @@ def _parse_achievements(char, rows):
187
199
----------
188
200
char: :class:`dict`[str,Any]
189
201
Dictionary where information will be stored.
190
- rows: :class:`List[ bs4.Tag]`
202
+ rows: List[ :class:`bs4.Tag`]
191
203
A list of all rows contained in the table.
192
204
"""
193
205
achievements = []
@@ -213,7 +225,7 @@ def _parse_character_information(char, rows):
213
225
----------
214
226
char: :class:`dict`[str,Any]
215
227
Dictionary where information will be stored.
216
- rows: :class:`List[ bs4.Tag]`
228
+ rows: List[ :class:`bs4.Tag`]
217
229
A list of all rows contained in the table.
218
230
"""
219
231
int_rows = ["level" , "achievement_points" ]
@@ -274,7 +286,7 @@ def _parse_deaths(char, rows):
274
286
----------
275
287
char: :class:`dict`[str,Any]
276
288
Dictionary where information will be stored.
277
- rows: :class:`List[ bs4.Tag]`
289
+ rows: List[ :class:`bs4.Tag`]
278
290
A list of all rows contained in the table.
279
291
"""
280
292
deaths = []
@@ -328,7 +340,7 @@ def _parse_other_characters(char, rows):
328
340
----------
329
341
char: :class:`dict`[str,Any]
330
342
Dictionary where information will be stored.
331
- rows: :class:`List[ bs4.Tag]`
343
+ rows: List[ :class:`bs4.Tag`]
332
344
A list of all rows contained in the table.
333
345
"""
334
346
char ["other_characters" ] = []
@@ -394,31 +406,27 @@ def _split_list(items, separator=",", last_separator=" and "):
394
406
return [e .strip () for e in items ]
395
407
396
408
@staticmethod
397
- def parse_to_json ( content , indent = None ):
398
- """Static method that creates a JSON string from the html content of the character's page .
409
+ def get_url ( name ):
410
+ """Gets the Tibia.com URl for a given character name .
399
411
400
412
Parameters
401
- -------------
402
- content: :class:`str`
403
- The HTML content of the page.
404
- indent: :class:`int`
405
- The number of spaces to indent the output with.
413
+ ------------
414
+ name: str
415
+ The name of the character
406
416
407
417
Returns
408
- ------------
409
- :class:`str`
410
- A string in JSON format."""
411
- char_dict = Character ._parse (content )
412
- return json .dumps (char_dict , indent = indent )
418
+ --------
419
+ str
420
+ The URL to the character's page"""
421
+ return CHARACTER_URL + urllib .parse .quote (name .encode ('iso-8859-1' ))
413
422
414
423
@staticmethod
415
424
def from_content (content ) -> Optional ['Character' ]:
416
425
"""Creates an instance of the class from the html content of the character's page.
417
426
418
-
419
427
Parameters
420
428
-----------
421
- content: str
429
+ content: :class:` str`
422
430
The HTML content of the page.
423
431
424
432
Returns
@@ -461,19 +469,23 @@ def from_content(content) -> Optional['Character']:
461
469
return char
462
470
463
471
@staticmethod
464
- def get_url ( name ):
465
- """Gets the Tibia.com URl for a given character name .
472
+ def parse_to_json ( content , indent = None ):
473
+ """Static method that creates a JSON string from the html content of the character's page .
466
474
467
475
Parameters
468
- ------------
469
- name: str
470
- The name of the character
476
+ -------------
477
+ content: :class:`str`
478
+ The HTML content of the page.
479
+ indent: :class:`int`
480
+ The number of spaces to indent the output with.
471
481
472
482
Returns
473
- --------
474
- str
475
- The URL to the character's page"""
476
- return CHARACTER_URL + urllib .parse .quote (name .encode ('iso-8859-1' ))
483
+ ------------
484
+ :class:`str`
485
+ A string in JSON format.
486
+ """
487
+ char_dict = Character ._parse (content )
488
+ return json .dumps (char_dict , indent = indent )
477
489
478
490
479
491
class Death :
0 commit comments