Parsers
tibiawikisql.parsers.base
¶
Classes:
| Name | Description |
|---|---|
AttributeParser |
Defines how to parser an attribute from a Wiki article into a python object. |
ParserMeta |
Metaclass for all parsers. |
BaseParser |
Base class that defines how to extract information from a Wiki template into a model. |
AttributeParser
¶
Bases: Generic[T]
Defines how to parser an attribute from a Wiki article into a python object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[[dict[str, str]], T]
|
A callable that takes the template's attributes as a parameter and returns a value. |
required |
fallback
|
D
|
Fallback value to set if the value is not found or the callable failed. |
...
|
Methods:
| Name | Description |
|---|---|
__call__ |
Perform parsing on the defined attribute. |
required |
Define a required attribute. |
optional |
Create optional attribute parser. Will fall back to None. |
status |
Create a parser for the commonly found "status" parameter. |
version |
Create a parser for the commonly found "implemented" parameter. |
Source code in tibiawikisql/parsers/base.py
__call__
¶
Perform parsing on the defined attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attributes
|
dict[str, str]
|
The template attributes. |
required |
Returns:
| Type | Description |
|---|---|
T | D
|
The result of the parser's function or the fallback value if applicable. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the parser function fails and no fallback was provided. |
Source code in tibiawikisql/parsers/base.py
required
classmethod
¶
Define a required attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field_name
|
str
|
The name of the template attribute in the wiki. |
required |
post_process
|
Callable[[str], T]
|
A function to call on the attribute's value. |
strip
|
Returns:
| Type | Description |
|---|---|
Self
|
An attribute parser expecting a required value. |
Source code in tibiawikisql/parsers/base.py
optional
classmethod
¶
optional(field_name: str, post_process: Callable[[str], T | None] = strip, default: T | None = None) -> Self
Create optional attribute parser. Will fall back to None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field_name
|
str
|
The name of the template attribute in the wiki. |
required |
post_process
|
Callable[[str], T | None]
|
A function to call on the attribute's value. |
strip
|
default
|
T | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
Self
|
An attribute parser for an optional value. |
Source code in tibiawikisql/parsers/base.py
status
classmethod
¶
Create a parser for the commonly found "status" parameter.
Returns:
| Type | Description |
|---|---|
Self
|
An attribute parser for the status parameter, falling back to "active" if not found. |
Source code in tibiawikisql/parsers/base.py
version
classmethod
¶
Create a parser for the commonly found "implemented" parameter.
Returns:
| Type | Description |
|---|---|
Self
|
An attribute parser for the implemented parameter. |
BaseParser
¶
Base class that defines how to extract information from a Wiki template into a model.
Methods:
| Name | Description |
|---|---|
parse_attributes |
Parse the attributes of an article into a mapping. |
from_article |
Parse an article into a TibiaWiki model. |
Attributes:
| Name | Type | Description |
|---|---|---|
template_name |
str
|
The name of the template that contains the information. |
model |
type[RowModel]
|
The model to convert the data into. |
table |
type[Table]
|
The SQL table where the data wil be stored. |
attribute_map |
dict[str, AttributeParser]
|
A map defining how to process every template attribute. |
template_name
class-attribute
¶
template_name: str = NotImplemented
The name of the template that contains the information.
table
class-attribute
¶
table: type[Table] = NotImplemented
The SQL table where the data wil be stored.
attribute_map
class-attribute
¶
attribute_map: dict[str, AttributeParser] = NotImplemented
A map defining how to process every template attribute.
parse_attributes
classmethod
¶
Parse the attributes of an article into a mapping.
By default, it will apply the attribute map, but it can be overridden to parse attributes in more complex ways.
It is called by parse_article.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article to extract the data from. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed attribute values. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the required template is not found. |
Source code in tibiawikisql/parsers/base.py
from_article
classmethod
¶
from_article(article: Article) -> M
Parse an article into a TibiaWiki model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article from where the model is parsed. |
required |
Returns:
| Type | Description |
|---|---|
M
|
An inherited model object for the current article. |
Source code in tibiawikisql/parsers/base.py
tibiawikisql.parsers.achievement
¶
Classes:
| Name | Description |
|---|---|
AchievementParser |
Parser for achievements. |
AchievementParser
¶
Bases: BaseParser
Parser for achievements.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = AchievementTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser(lambda x: x.get('actualname') or x.get('name')), 'grade': AttributeParser.optional('grade', parse_integer), 'points': AttributeParser.optional('points', parse_integer), 'is_premium': AttributeParser.optional('premium', parse_boolean, False), 'is_secret': AttributeParser.optional('secret', parse_boolean, False), 'description': AttributeParser.required('description', clean_links), 'spoiler': AttributeParser.optional('spoiler', clean_links), 'achievement_id': AttributeParser.optional('achievementid', parse_integer), 'version': AttributeParser.optional('implemented'), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
tibiawikisql.parsers.book
¶
Classes:
| Name | Description |
|---|---|
BookParser |
Parser for book articles. |
BookParser
¶
Bases: BaseParser
Parser for book articles.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = BookTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.required('title'), 'book_type': AttributeParser.optional('booktype', clean_links), 'location': AttributeParser.optional('location', lambda x: clean_links(x, True)), 'blurb': AttributeParser.optional('blurb', lambda x: clean_links(x, True)), 'author': AttributeParser.optional('author', lambda x: clean_links(x, True)), 'prev_book': AttributeParser.optional('prevbook'), 'next_book': AttributeParser.optional('nextbook'), 'text': AttributeParser.required('text', clean_links), 'version': AttributeParser.optional('implemented'), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
tibiawikisql.parsers.charm
¶
Classes:
| Name | Description |
|---|---|
CharmParser |
Parser for charms. |
CharmParser
¶
Bases: BaseParser
Parser for charms.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = CharmTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser(lambda x: x.get('actualname') or x.get('name')), 'type': AttributeParser(lambda x: x.get('type')), 'effect': AttributeParser(lambda x: clean_links(x.get('effect'))), 'cost': AttributeParser(lambda x: parse_integer(x.get('cost'))), 'version': AttributeParser(lambda x: x.get('implemented'), None), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
tibiawikisql.parsers.creature
¶
Classes:
| Name | Description |
|---|---|
CreatureParser |
Parses creatures or monsters. |
Functions:
| Name | Description |
|---|---|
parse_maximum_damage |
Parse the maximum damage template from TibiaWiki. |
parse_maximum_integer |
From a string, finds the highest integer found. |
parse_loot |
Get every item drop entry of a creature's drops. |
parse_abilities |
Parse the abilities of a creature. |
parse_monster_walks |
Match the values against a regex to filter typos or bad data on the wiki. |
CreatureParser
¶
Bases: BaseParser
Parses creatures or monsters.
Methods:
| Name | Description |
|---|---|
parse_attributes |
Parse the attributes of an article into a mapping. |
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
template_name |
The name of the template that contains the information. |
|
table |
The SQL table where the data wil be stored. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
table
class-attribute
instance-attribute
¶
table = tibiawikisql.schema.CreatureTable
The SQL table where the data wil be stored.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser(lambda x: x.get('actualname') or x.get('name')), 'article': AttributeParser.optional('article'), 'plural': AttributeParser.optional('plural'), 'library_race': AttributeParser.optional('bestiaryname'), 'creature_class': AttributeParser.optional('creatureclass'), 'type_primary': AttributeParser.optional('primarytype'), 'type_secondary': AttributeParser.optional('secondarytype'), 'bestiary_class': AttributeParser.optional('bestiaryclass'), 'bestiary_level': AttributeParser.optional('bestiarylevel'), 'bestiary_occurrence': AttributeParser.optional('occurrence'), 'bosstiary_class': AttributeParser.optional('bosstiaryclass'), 'hitpoints': AttributeParser.optional('hp', parse_integer), 'experience': AttributeParser.optional('exp', parse_integer), 'armor': AttributeParser.optional('armor', parse_integer), 'mitigation': AttributeParser.optional('mitigation', parse_float), 'speed': AttributeParser.optional('speed', parse_integer), 'runs_at': AttributeParser.optional('runsat', parse_integer), 'summon_cost': AttributeParser.optional('summon', parse_integer), 'convince_cost': AttributeParser.optional('convince', parse_integer), 'illusionable': AttributeParser.optional('illusionable', parse_boolean), 'pushable': AttributeParser.optional('pushable', parse_boolean), 'push_objects': AttributeParser.optional('pushobjects', parse_boolean), 'sees_invisible': AttributeParser.optional('senseinvis', parse_boolean), 'paralysable': AttributeParser.optional('paraimmune', parse_boolean), 'spawn_type': AttributeParser.optional('spawntype'), 'is_boss': AttributeParser.optional('isboss', parse_boolean, False), 'cooldown': AttributeParser.optional('cooldown', parse_float), 'modifier_physical': AttributeParser.optional('physicalDmgMod', parse_integer), 'modifier_earth': AttributeParser.optional('earthDmgMod', parse_integer), 'modifier_fire': AttributeParser.optional('fireDmgMod', parse_integer), 'modifier_energy': AttributeParser.optional('energyDmgMod', parse_integer), 'modifier_ice': AttributeParser.optional('iceDmgMod', parse_integer), 'modifier_death': AttributeParser.optional('deathDmgMod', parse_integer), 'modifier_holy': AttributeParser.optional('holyDmgMod', parse_integer), 'modifier_drown': AttributeParser.optional('drownDmgMod', parse_integer), 'modifier_lifedrain': AttributeParser.optional('hpDrainDmgMod', parse_integer), 'modifier_healing': AttributeParser.optional('healMod', parse_integer), 'walks_through': AttributeParser.optional('walksthrough', parse_monster_walks), 'walks_around': AttributeParser.optional('walksaround', parse_monster_walks), 'location': AttributeParser.optional('location', clean_links), 'version': AttributeParser.optional('implemented'), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
parse_attributes
classmethod
¶
Parse the attributes of an article into a mapping.
By default, it will apply the attribute map, but it can be overridden to parse attributes in more complex ways.
It is called by parse_article.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article to extract the data from. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed attribute values. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the required template is not found. |
Source code in tibiawikisql/parsers/creature.py
parse_maximum_damage
¶
Parse the maximum damage template from TibiaWiki.
If no template is found, the highest number found is considered the total damage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
A string containing the creature's max damage. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
A dictionary containing the maximum damage by element if available. |
Source code in tibiawikisql/parsers/creature.py
parse_maximum_integer
¶
From a string, finds the highest integer found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The string containing integers. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
The highest number found, or None if no number is found. |
Source code in tibiawikisql/parsers/creature.py
parse_loot
¶
Get every item drop entry of a creature's drops.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
A string containing item drops. |
required |
Return
A list of tuples containing the name of the item and the amount dropped (or empty for 1).
Source code in tibiawikisql/parsers/creature.py
parse_abilities
¶
Parse the abilities of a creature.
Args: value: A string containing the creature's abilities definition.
Returns:
| Type | Description |
|---|---|
list[dict[str, str]]
|
A list of dictionaries with the ability data. |
Source code in tibiawikisql/parsers/creature.py
parse_monster_walks
¶
Match the values against a regex to filter typos or bad data on the wiki.
Element names followed by any character that is not a comma will be considered unknown and will not be returned.
Examples:
Poison?, firewill returnfire.Poison?, fire?.will return neither.Poison, earth, fire?, [[ice]]will returnpoison,earth.No,--,>, orNonewill returnNone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The string containing possible field types. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
A list of field types, separated by commas. |
Source code in tibiawikisql/parsers/creature.py
tibiawikisql.parsers.house
¶
Classes:
| Name | Description |
|---|---|
HouseParser |
Parses houses and guildhalls. |
HouseParser
¶
Bases: BaseParser
Parses houses and guildhalls.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = tibiawikisql.schema.HouseTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'house_id': AttributeParser.required('houseid', parse_integer), 'name': AttributeParser.required('name'), 'is_guildhall': AttributeParser.required('type', lambda x: x is not None and 'guildhall' in x.lower()), 'city': AttributeParser.required('city'), 'street': AttributeParser.optional('street'), 'location': AttributeParser.optional('location', clean_links), 'beds': AttributeParser.required('beds', parse_integer), 'rent': AttributeParser.required('rent', parse_integer), 'size': AttributeParser.required('size', parse_integer), 'rooms': AttributeParser.optional('rooms', parse_integer), 'floors': AttributeParser.optional('floors', parse_integer), 'x': AttributeParser.optional('posx', convert_tibiawiki_position), 'y': AttributeParser.optional('posy', convert_tibiawiki_position), 'z': AttributeParser.optional('posz', int), 'version': AttributeParser.version(), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
tibiawikisql.parsers.imbuement
¶
Classes:
| Name | Description |
|---|---|
ImbuementParser |
Parses imbuements. |
Functions:
| Name | Description |
|---|---|
parse_astral_sources |
Parse the astral sources of an imbuement. |
parse_effect |
Parse TibiaWiki's effect template into a string effect. |
parse_slots |
Parse the list of slots. |
ImbuementParser
¶
Bases: BaseParser
Parses imbuements.
Methods:
| Name | Description |
|---|---|
parse_attributes |
Parse the attributes of an article into a mapping. |
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = ImbuementTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.required('name'), 'tier': AttributeParser.required('prefix'), 'type': AttributeParser.required('type'), 'category': AttributeParser.required('category'), 'effect': AttributeParser.required('effect', parse_effect), 'version': AttributeParser.required('implemented'), 'slots': AttributeParser.required('slots', parse_slots), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
parse_attributes
classmethod
¶
Parse the attributes of an article into a mapping.
By default, it will apply the attribute map, but it can be overridden to parse attributes in more complex ways.
It is called by parse_article.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article to extract the data from. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed attribute values. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the required template is not found. |
Source code in tibiawikisql/parsers/imbuement.py
parse_astral_sources
¶
Parse the astral sources of an imbuement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
A string containing astral sources. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
A dictionary containing the material name and te amount required. |
Source code in tibiawikisql/parsers/imbuement.py
parse_effect
¶
Parse TibiaWiki's effect template into a string effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
effect
|
str
|
The string containing the template. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The effect string. |
Source code in tibiawikisql/parsers/imbuement.py
tibiawikisql.parsers.item
¶
Classes:
| Name | Description |
|---|---|
ItemParser |
Parses items and objects. |
ItemParser
¶
Bases: BaseParser
Parses items and objects.
Methods:
| Name | Description |
|---|---|
parse_attributes |
Parse the attributes of an article into a mapping. |
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = ItemTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.required('name'), 'actual_name': AttributeParser.optional('actualname'), 'plural': AttributeParser.optional('plural', clean_question_mark), 'article': AttributeParser.optional('article'), 'is_marketable': AttributeParser.optional('marketable', parse_boolean, False), 'is_stackable': AttributeParser.optional('stackable', parse_boolean, False), 'is_pickupable': AttributeParser.optional('pickupable', parse_boolean, False), 'is_immobile': AttributeParser.optional('immobile', parse_boolean, False), 'value_sell': AttributeParser.optional('npcvalue', parse_integer), 'value_buy': AttributeParser.optional('npcprice', parse_integer), 'weight': AttributeParser.optional('weight', parse_float), 'flavor_text': AttributeParser.optional('flavortext'), 'item_class': AttributeParser.optional('objectclass'), 'item_type': AttributeParser.optional('primarytype'), 'type_secondary': AttributeParser.optional('secondarytype'), 'light_color': AttributeParser.optional('lightcolor', lambda x: client_color_to_rgb(parse_integer(x))), 'light_radius': AttributeParser.optional('lightradius', parse_integer), 'version': AttributeParser.optional('implemented'), 'client_id': AttributeParser.optional('itemid', parse_integer), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
parse_attributes
classmethod
¶
Parse the attributes of an article into a mapping.
By default, it will apply the attribute map, but it can be overridden to parse attributes in more complex ways.
It is called by parse_article.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article to extract the data from. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed attribute values. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the required template is not found. |
Source code in tibiawikisql/parsers/item.py
tibiawikisql.parsers.key
¶
Classes:
| Name | Description |
|---|---|
KeyParser |
Parser for keys. |
KeyParser
¶
Bases: BaseParser
Parser for keys.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = tibiawikisql.schema.ItemKeyTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.optional('aka', clean_links), 'number': AttributeParser.optional('number', parse_integer), 'material': AttributeParser.optional('primarytype'), 'location': AttributeParser.optional('location', clean_links), 'notes': AttributeParser.optional('shortnotes', clean_links), 'origin': AttributeParser.optional('origin', clean_links), 'status': AttributeParser.status(), 'version': AttributeParser.optional('implemented', clean_links)}
A map defining how to process every template attribute.
tibiawikisql.parsers.mount
¶
Classes:
| Name | Description |
|---|---|
MountParser |
Parser for mounts. |
Functions:
| Name | Description |
|---|---|
remove_mount |
Remove "(Mount)" from the name, if found. |
MountParser
¶
Bases: BaseParser
Parser for mounts.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = tibiawikisql.schema.MountTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.required('name', remove_mount), 'speed': AttributeParser.required('speed', int), 'taming_method': AttributeParser.required('taming_method', clean_links), 'is_buyable': AttributeParser.optional('bought', parse_boolean, False), 'price': AttributeParser.optional('price', parse_integer), 'achievement': AttributeParser.optional('achievement'), 'light_color': AttributeParser.optional('lightcolor', lambda x: client_color_to_rgb(parse_integer(x))), 'light_radius': AttributeParser.optional('lightradius', int), 'version': AttributeParser.version(), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
tibiawikisql.parsers.npc
¶
Classes:
| Name | Description |
|---|---|
NpcParser |
Parser for NPCs. |
NpcParser
¶
Bases: BaseParser
Parser for NPCs.
Methods:
| Name | Description |
|---|---|
parse_attributes |
Parse the attributes of an article into a mapping. |
Attributes:
| Name | Type | Description |
|---|---|---|
table |
The SQL table where the data wil be stored. |
|
model |
The model to convert the data into. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = tibiawikisql.schema.NpcTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser(lambda x: x.get('actualname') or x.get('name')), 'gender': AttributeParser.optional('gender'), 'location': AttributeParser.optional('location', clean_links), 'subarea': AttributeParser.optional('subarea'), 'city': AttributeParser.required('city'), 'x': AttributeParser.optional('posx', convert_tibiawiki_position), 'y': AttributeParser.optional('posy', convert_tibiawiki_position), 'z': AttributeParser.optional('posz', int), 'version': AttributeParser.optional('implemented'), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
parse_attributes
classmethod
¶
Parse the attributes of an article into a mapping.
By default, it will apply the attribute map, but it can be overridden to parse attributes in more complex ways.
It is called by parse_article.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article to extract the data from. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed attribute values. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the required template is not found. |
Source code in tibiawikisql/parsers/npc.py
tibiawikisql.parsers.outfit
¶
Classes:
| Name | Description |
|---|---|
OutfitParser |
Parser for outfits. |
OutfitParser
¶
Bases: BaseParser
Parser for outfits.
Methods:
| Name | Description |
|---|---|
parse_attributes |
Parse the attributes of an article into a mapping. |
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = tibiawikisql.schema.OutfitTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.required('name'), 'outfit_type': AttributeParser.required('primarytype'), 'is_premium': AttributeParser.optional('premium', parse_boolean, False), 'is_tournament': AttributeParser.optional('tournament', parse_boolean, False), 'is_bought': AttributeParser.optional('bought', parse_boolean, False), 'full_price': AttributeParser.optional('fulloutfitprice', parse_integer), 'achievement': AttributeParser.optional('achievement'), 'status': AttributeParser.status(), 'version': AttributeParser.version()}
A map defining how to process every template attribute.
parse_attributes
classmethod
¶
Parse the attributes of an article into a mapping.
By default, it will apply the attribute map, but it can be overridden to parse attributes in more complex ways.
It is called by parse_article.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article to extract the data from. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed attribute values. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the required template is not found. |
Source code in tibiawikisql/parsers/outfit.py
tibiawikisql.parsers.quest
¶
Classes:
| Name | Description |
|---|---|
QuestParser |
Parser for quests. |
Functions:
| Name | Description |
|---|---|
parse_links |
Find all the links in a string and returns a list of them. |
QuestParser
¶
Bases: BaseParser
Parser for quests.
Methods:
| Name | Description |
|---|---|
parse_attributes |
Parse the attributes of an article into a mapping. |
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = QuestTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.required('name', html.unescape), 'location': AttributeParser.optional('location', clean_links), 'is_rookgaard_quest': AttributeParser.optional('rookgaardquest', parse_boolean, False), 'type': AttributeParser.optional('type'), 'quest_log': AttributeParser.optional('log', parse_boolean), 'legend': AttributeParser.optional('legend', clean_links), 'level_required': AttributeParser.optional('lvl', parse_integer), 'level_recommended': AttributeParser.optional('lvlrec', parse_integer), 'active_time': AttributeParser.optional('time'), 'estimated_time': AttributeParser.optional('timealloc'), 'is_premium': AttributeParser.required('premium', parse_boolean), 'version': AttributeParser.optional('implemented'), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
parse_attributes
classmethod
¶
Parse the attributes of an article into a mapping.
By default, it will apply the attribute map, but it can be overridden to parse attributes in more complex ways.
It is called by parse_article.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article to extract the data from. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed attribute values. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the required template is not found. |
tibiawikisql.parsers.spell
¶
Classes:
| Name | Description |
|---|---|
SpellParser |
Parser for spells. |
SpellParser
¶
Bases: BaseParser
Parser for spells.
Methods:
| Name | Description |
|---|---|
parse_attributes |
Parse the attributes of an article into a mapping. |
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = tibiawikisql.schema.SpellTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.required('name'), 'effect': AttributeParser.required('effect', clean_links), 'words': AttributeParser.optional('words'), 'spell_type': AttributeParser.required('type'), 'group_spell': AttributeParser.required('subclass'), 'group_secondary': AttributeParser.optional('secondarygroup'), 'group_rune': AttributeParser.optional('runegroup'), 'element': AttributeParser.optional('damagetype'), 'base_power': AttributeParser.optional('basepower', parse_integer), 'mana': AttributeParser.optional('mana', parse_integer), 'soul': AttributeParser.optional('soul', parse_integer, 0), 'cooldown': AttributeParser.required('cooldown'), 'cooldown2': AttributeParser.optional('cooldown2'), 'cooldown3': AttributeParser.optional('cooldown3'), 'cooldown_group': AttributeParser.optional('cooldowngroup'), 'cooldown_group_secondary': AttributeParser.optional('cooldowngroup2'), 'level': AttributeParser.optional('levelrequired', parse_integer), 'is_premium': AttributeParser.optional('premium', parse_boolean, False), 'is_promotion': AttributeParser.optional('promotion', parse_boolean, False), 'is_wheel_spell': AttributeParser.optional('wheelspell', parse_boolean, False), 'is_passive': AttributeParser.optional('passivespell', parse_boolean, False), 'version': AttributeParser.optional('implemented'), 'status': AttributeParser.status()}
A map defining how to process every template attribute.
parse_attributes
classmethod
¶
parse_attributes(article: Article)
Parse the attributes of an article into a mapping.
By default, it will apply the attribute map, but it can be overridden to parse attributes in more complex ways.
It is called by parse_article.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
article
|
Article
|
The article to extract the data from. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed attribute values. |
Raises:
| Type | Description |
|---|---|
AttributeParsingError
|
If the required template is not found. |
Source code in tibiawikisql/parsers/spell.py
tibiawikisql.parsers.update
¶
Classes:
| Name | Description |
|---|---|
UpdateParser |
Parser for game updates. |
UpdateParser
¶
Bases: BaseParser
Parser for game updates.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
The model to convert the data into. |
|
table |
The SQL table where the data wil be stored. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = UpdateTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.optional('name'), 'type_primary': AttributeParser.required('primarytype'), 'type_secondary': AttributeParser.optional('secondarytype'), 'release_date': AttributeParser.required('date', parse_date), 'news_id': AttributeParser.optional('newsid', parse_integer), 'previous': AttributeParser.optional('previous'), 'next': AttributeParser.optional('next'), 'summary': AttributeParser.optional('summary', clean_links), 'changes': AttributeParser.optional('changelist', clean_links), 'version': AttributeParser.version()}
A map defining how to process every template attribute.
tibiawikisql.parsers.world
¶
Classes:
| Name | Description |
|---|---|
WorldParser |
Parser for game worlds (servers). |
WorldParser
¶
Bases: BaseParser
Parser for game worlds (servers).
Attributes:
| Name | Type | Description |
|---|---|---|
table |
The SQL table where the data wil be stored. |
|
model |
The model to convert the data into. |
|
template_name |
The name of the template that contains the information. |
|
attribute_map |
ClassVar
|
A map defining how to process every template attribute. |
table
class-attribute
instance-attribute
¶
table = tibiawikisql.schema.WorldTable
The SQL table where the data wil be stored.
template_name
class-attribute
instance-attribute
¶
The name of the template that contains the information.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {'name': AttributeParser.required('name'), 'location': AttributeParser.required('location'), 'pvp_type': AttributeParser.required('type'), 'is_preview': AttributeParser.optional('preview', parse_boolean, False), 'is_experimental': AttributeParser.optional('experimental', parse_boolean, False), 'online_since': AttributeParser.required('online', parse_date), 'offline_since': AttributeParser.optional('offline', parse_date), 'merged_into': AttributeParser.optional('mergedinto'), 'battleye': AttributeParser.optional('battleye', parse_boolean, False), 'battleye_type': AttributeParser.optional('battleyetype'), 'protected_since': AttributeParser.optional('protectedsince', parse_date), 'world_board': AttributeParser.optional('worldboardid', parse_integer), 'trade_board': AttributeParser.optional('tradeboardid', parse_integer)}
A map defining how to process every template attribute.