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: get("actualname") or get("name")
),
"grade": optional("grade", parse_integer),
"points": optional("points", parse_integer),
"is_premium": optional("premium", parse_boolean, False),
"is_secret": optional("secret", parse_boolean, False),
"description": required("description", clean_links),
"spoiler": optional("spoiler", clean_links),
"achievement_id": optional(
"achievementid", parse_integer
),
"version": optional("implemented"),
"status": 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": required("title"),
"book_type": optional("booktype", clean_links),
"location": optional(
"location", lambda x: clean_links(x, True)
),
"blurb": optional(
"blurb", lambda x: clean_links(x, True)
),
"author": optional(
"author", lambda x: clean_links(x, True)
),
"prev_book": optional("prevbook"),
"next_book": optional("nextbook"),
"text": required("text", clean_links),
"version": optional("implemented"),
"status": 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: get("actualname") or get("name")
),
"type": AttributeParser(lambda x: get("type")),
"effect": AttributeParser(
lambda x: clean_links(get("effect"))
),
"cost": AttributeParser(
lambda x: parse_integer(get("cost"))
),
"version": AttributeParser(
lambda x: get("implemented"), None
),
"status": 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 = CreatureTable
The SQL table where the data wil be stored.
attribute_map
class-attribute
instance-attribute
¶
attribute_map: ClassVar = {
"name": AttributeParser(
lambda x: get("actualname") or get("name")
),
"article": optional("article"),
"plural": optional("plural"),
"library_race": optional("bestiaryname"),
"creature_class": optional("creatureclass"),
"type_primary": optional("primarytype"),
"type_secondary": optional("secondarytype"),
"bestiary_class": optional("bestiaryclass"),
"bestiary_level": optional("bestiarylevel"),
"bestiary_occurrence": optional("occurrence"),
"bosstiary_class": optional("bosstiaryclass"),
"hitpoints": optional("hp", parse_integer),
"experience": optional("exp", parse_integer),
"armor": optional("armor", parse_integer),
"mitigation": optional("mitigation", parse_integer),
"speed": optional("speed", parse_integer),
"runs_at": optional("runsat", parse_integer),
"summon_cost": optional("summon", parse_integer),
"convince_cost": optional("convince", parse_integer),
"illusionable": optional("illusionable", parse_boolean),
"pushable": optional("pushable", parse_boolean),
"push_objects": optional("pushobjects", parse_boolean),
"sees_invisible": optional("senseinvis", parse_boolean),
"paralysable": optional("paraimmune", parse_boolean),
"spawn_type": optional("spawntype"),
"is_boss": optional("isboss", parse_boolean, False),
"cooldown": optional("cooldown", parse_float),
"modifier_physical": optional(
"physicalDmgMod", parse_integer
),
"modifier_earth": optional(
"earthDmgMod", parse_integer
),
"modifier_fire": optional("fireDmgMod", parse_integer),
"modifier_energy": optional("iceDmgMod", parse_integer),
"modifier_ice": optional("energyDmgMod", parse_integer),
"modifier_death": optional(
"deathDmgMod", parse_integer
),
"modifier_holy": optional("holyDmgMod", parse_integer),
"modifier_drown": optional(
"drownDmgMod", parse_integer
),
"modifier_lifedrain": optional(
"hpDrainDmgMod", parse_integer
),
"modifier_healing": optional("healMod", parse_integer),
"walks_through": optional(
"walksthrough", parse_monster_walks
),
"walks_around": optional(
"walksaround", parse_monster_walks
),
"location": optional("location", clean_links),
"version": optional("implemented"),
"status": 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 = 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": required("houseid", parse_integer),
"name": required("name"),
"is_guildhall": required(
"type",
lambda x: x is not None and "guildhall" in lower(),
),
"city": required("city"),
"street": optional("street"),
"location": optional("location", clean_links),
"beds": required("beds", parse_integer),
"rent": required("rent", parse_integer),
"size": required("size", parse_integer),
"rooms": optional("rooms", parse_integer),
"floors": optional("floors", parse_integer),
"x": optional("posx", convert_tibiawiki_position),
"y": optional("posy", convert_tibiawiki_position),
"z": optional("posz", int),
"version": version(),
"status": 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": required("name"),
"tier": required("prefix"),
"type": required("type"),
"category": required("category"),
"effect": required("effect", parse_effect),
"version": required("implemented"),
"slots": required("slots", parse_slots),
"status": 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": required("name"),
"actual_name": optional("actualname"),
"plural": optional("plural", clean_question_mark),
"article": optional("article"),
"is_marketable": optional(
"marketable", parse_boolean, False
),
"is_stackable": optional(
"stackable", parse_boolean, False
),
"is_pickupable": optional(
"pickupable", parse_boolean, False
),
"is_immobile": optional(
"immobile", parse_boolean, False
),
"value_sell": optional("npcvalue", parse_integer),
"value_buy": optional("npcprice", parse_integer),
"weight": optional("weight", parse_float),
"flavor_text": optional("flavortext"),
"item_class": optional("objectclass"),
"item_type": optional("primarytype"),
"type_secondary": optional("secondarytype"),
"light_color": optional(
"lightcolor",
lambda x: client_color_to_rgb(parse_integer(x)),
),
"light_radius": optional("lightradius", parse_integer),
"version": optional("implemented"),
"client_id": optional("itemid", parse_integer),
"status": 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 = 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": optional("aka", clean_links),
"number": optional("number", parse_integer),
"material": optional("primarytype"),
"location": optional("location", clean_links),
"notes": optional("shortnotes", clean_links),
"origin": optional("origin", clean_links),
"status": status(),
"version": 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 = 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": required("name", remove_mount),
"speed": required("speed", int),
"taming_method": required("taming_method", clean_links),
"is_buyable": optional("bought", parse_boolean, False),
"price": optional("price", parse_integer),
"achievement": optional("achievement"),
"light_color": optional(
"lightcolor",
lambda x: client_color_to_rgb(parse_integer(x)),
),
"light_radius": optional("lightradius", int),
"version": version(),
"status": 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 = 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: get("actualname") or get("name")
),
"gender": optional("gender"),
"location": optional("location", clean_links),
"subarea": optional("subarea"),
"city": required("city"),
"x": optional("posx", convert_tibiawiki_position),
"y": optional("posy", convert_tibiawiki_position),
"z": optional("posz", int),
"version": optional("implemented"),
"status": 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 = 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": required("name"),
"outfit_type": required("primarytype"),
"is_premium": optional("premium", parse_boolean, False),
"is_tournament": optional(
"tournament", parse_boolean, False
),
"is_bought": optional("bought", parse_boolean, False),
"full_price": optional(
"fulloutfitprice", parse_integer
),
"achievement": optional("achievement"),
"status": status(),
"version": 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": required("name", unescape),
"location": optional("location", clean_links),
"is_rookgaard_quest": optional(
"rookgaardquest", parse_boolean, False
),
"type": optional("type"),
"quest_log": optional("log", parse_boolean),
"legend": optional("legend", clean_links),
"level_required": optional("lvl", parse_integer),
"level_recommended": optional("lvlrec", parse_integer),
"active_time": optional("time"),
"estimated_time": optional("timealloc"),
"is_premium": required("premium", parse_boolean),
"version": optional("implemented"),
"status": 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 = 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": required("name"),
"effect": required("effect", clean_links),
"words": optional("words"),
"spell_type": required("type"),
"group_spell": required("subclass"),
"group_secondary": optional("secondarygroup"),
"group_rune": optional("runegroup"),
"element": optional("damagetype"),
"mana": optional("mana", parse_integer),
"soul": optional("soul", parse_integer, 0),
"price": optional("spellcost", parse_integer),
"cooldown": required("cooldown"),
"cooldown2": optional("cooldown2"),
"cooldown3": optional("cooldown3"),
"cooldown_group": optional("cooldowngroup"),
"cooldown_group_secondary": optional("cooldowngroup2"),
"level": optional("levelrequired", parse_integer),
"is_premium": optional("premium", parse_boolean, False),
"is_promotion": optional(
"promotion", parse_boolean, False
),
"is_wheel_spell": optional(
"wheelspell", parse_boolean, False
),
"is_passive": optional(
"passivespell", parse_boolean, False
),
"version": optional("implemented"),
"status": 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": optional("name"),
"type_primary": required("primarytype"),
"type_secondary": optional("secondarytype"),
"release_date": required("date", parse_date),
"news_id": optional("newsid", parse_integer),
"previous": optional("previous"),
"next": optional("next"),
"summary": optional("summary", clean_links),
"changes": optional("changelist", clean_links),
"version": 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 = 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": required("name"),
"location": required("location"),
"pvp_type": required("type"),
"is_preview": optional("preview", parse_boolean, False),
"is_experimental": optional(
"experimental", parse_boolean, False
),
"online_since": required("online", parse_date),
"offline_since": optional("offline", parse_date),
"merged_into": optional("mergedinto"),
"battleye": optional("battleye", parse_boolean, False),
"battleye_type": optional("battleyetype"),
"protected_since": optional(
"protectedsince", parse_date
),
"world_board": optional("worldboardid", parse_integer),
"trade_board": optional("tradeboardid", parse_integer),
}
A map defining how to process every template attribute.