Wiki Export Handler

Overview

Path PyPoE/cli/exporter/wiki/parser.py
Version 1.0.0a0
Revision $Id: 90b1d08ed9a49ec12ba705198a91c9c32dab36f7 $
Author Omega_K2

Description

Base classes and related functions for Wiki Export Handlers.

Agreement

See PyPoE/LICENSE

Documentation

Classes

class PyPoE.cli.exporter.wiki.parser.BaseParser(base_path)[source]

Bases: object

Variables:
  • base_path (str) –
  • rr
  • tc
  • custom
class PyPoE.cli.exporter.wiki.parser.WikiCondition(data, cmdargs)[source]

Bases: object

class PyPoE.cli.exporter.wiki.parser.TagHandler(rr)[source]

Bases: object

Provides tag handlers for use with parse_description_tags()

Parameters:tag_handlers (dict[str, callable]) – dictionary containing tags and a callable function for passing to parse_description_tags()
__init__(rr)[source]
Parameters:rr (RelationalReader) – RelationalReader instance to use when looking up whether items are ‘real’ for linking purposes

Functions

PyPoE.cli.exporter.wiki.parser.find_template(wikitext, template_name)[source]

Finds a template within wikitext and parses the arguments.

Parameters:
  • wikitext (string) – wiktext
  • template_name (string) – Name of the template to find
Returns:

returns a dictionary containing 3 keys:

texts: list[str]

text not included in the template itself; each template call inbetween

args: list[str]

positional arguments passed to the template

kwargs: OrderedDict[str, str]

keyword arguments passed to the template in the order they appeared in the wikitext

Return type:

dict[str, object]

PyPoE.cli.exporter.wiki.parser.format_result_rows(parsed_args, ordered_dict, template_name, indent=32)[source]

Formats the given result rows as mediawiki template or module.

Parameters:
  • parsed_args – argument parser argument containing the format argument
  • ordered_dict (OrderedDict) – OrderedDict instance of the rows to format
  • template_name (str) – name of the template
  • indent (int) – number of spaces to use for indentation/padding up to the given size
Returns:

out – formatted string

Return type:

str

Formats the given string according to the predefined inter wiki formatting rules and returns it.

Parameters:string (str) – String to format
Returns:String formatted with inter wiki links
Return type:str
PyPoE.cli.exporter.wiki.parser.parse_and_handle_description_tags(rr, text)[source]

Parses and handles description texts

Parameters:
  • rr (RelationalReader) – RelationalReader instance to pass to TagHandler when parsing
  • text (str) – Text which to parse
Returns:

Parsed texts with wiki templates/links

Return type:

str