Overview

Path PyPoE/poe/text.py
Version 1.0.0a0
Revision $Id: 703f14cb092b667c48f057c57bb2d1db129ba348 $
Author Omega_K2

Description

Utilities for dealing with certain text/string related tasks in regards to PoE.

Agreement

See PyPoE/LICENSE

Documentation

class PyPoE.poe.text.Tag(id=None, parent=None, children=None, parameter=None)[source]

Bases: PyPoE.shared.mixins.ReprMixin

Represents a tag in PoE texts.

For example:

<size:45>{I have <item>{My item} for sale}

tag.id = ‘size’ tag.parent = None tag.children = [‘I have ‘, <Tag object>, ‘ for sale’] tag.parameter = ‘45’

Parameters:
  • id (str) – identifier string of the tag
  • parent (tag) – parent Tag instance if any
  • children (list[str or Tag]) – list of child strings or tag instances
  • parameter (str) – parameter specified in the text to this tag if any
__init__(id=None, parent=None, children=None, parameter=None)[source]
Parameters:
  • id (str) – identifier string of the tag
  • parent (tag) – parent Tag instance if any
  • children (list[str or Tag]) – list of child strings or tag instances
  • parameter (str) – parameter specified in the text to this tag if any
handle_tags(handlers)[source]

Handle this and child tags with the handlers passed to this function.

Parameters:handlers (dict[str, callable]) –

Dictionary containing a mapping of handler ids to callables that handle them.

The callable will be passed two keyword parameters:
hstr - the current contained string for the parameter to handle parameter - any parameters passed to the tag (may be None)
Returns:The handled string
Return type:str
Raises:KeyError – if a id is not present in the handlers parameter
root()[source]

Returns the root Tag node

Returns:root node
Return type:Tag
PyPoE.poe.text.parse_description_tags(text)[source]

Parses a text containing description tags into Tag classes which can be used for further handling.

Parameters:text (str) – The text to parse
Returns:the parsed text as Tag class (with no id)
Return type:Tag