Ver código fonte

Update mwparserfromhell usage to reflect current API.

tags/v0.1^2
Ben Kurtovic 12 anos atrás
pai
commit
a7e243fdfb
1 arquivos alterados com 3 adições e 6 exclusões
  1. +3
    -6
      earwigbot/wiki/page.py

+ 3
- 6
earwigbot/wiki/page.py Ver arquivo

@@ -707,13 +707,10 @@ class Page(CopyvioMixIn):
"""Parse the page content for templates, links, etc.

Actual parsing is handled by :py:mod:`mwparserfromhell`. Raises
:py:exc:`ImportError` if :py:mod:`mwparserfromhell` isn't installed,
and :py:exc:`~earwigbot.exceptions.InvalidPageError` or
:py:exc:`~earwigbot.exceptions.InvalidPageError` or
:py:exc:`~earwigbot.exceptions.PageNotFoundError` if the page name is
invalid or the page does not exist, respectively.
"""
if not mwparserfromhell:
raise ImportError("mwparserfromhell")
return mwparserfromhell.parse(self.get())

def edit(self, text, summary, minor=False, bot=True, force=False):
@@ -765,7 +762,7 @@ class Page(CopyvioMixIn):
``{{bots|optout=orfud,norationale,replaceable}}``.
"""
def parse_param(template, param):
value = template.get_param(param).value
value = template.get(param).value
return [item.strip().lower() for item in value.split(",")]

if not username:
@@ -776,7 +773,7 @@ class Page(CopyvioMixIn):
optouts = [optout.lower() for optout in optouts] if optouts else []

r_bots = "\{\{\s*(no)?bots\s*(\||\}\})"
filter = self.parse().ifilter_templates(matches=r_bots, recursive=True)
filter = self.parse().ifilter_templates(recursive=True, matches=r_bots)
for template in filter:
if template.has_param("deny"):
denies = parse_param(template, "deny")


Carregando…
Cancelar
Salvar