Przeglądaj źródła

Use rvslots when fetching revision content

main
Ben Kurtovic 5 lat temu
rodzic
commit
8fec94a82b
3 zmienionych plików z 14 dodań i 8 usunięć
  1. +6
    -3
      commands/rc_monitor.py
  2. +4
    -2
      tasks/afc_statistics.py
  3. +4
    -3
      tasks/banner_untag.py

+ 6
- 3
commands/rc_monitor.py Wyświetl plik

@@ -126,6 +126,7 @@ class RCMonitor(Command):
try:
result = site.api_query(
action="query", prop="revisions", rvprop="ids|content",
rvslots="main",
revids=(oldrev + "|" + newrev) if oldrev else newrev)
except APIError:
return None
@@ -140,14 +141,16 @@ class RCMonitor(Command):

if not oldrev:
try:
text = revs[0]["*"]
text = revs[0]["slots"]["main"]["*"]
except (IndexError, KeyError):
return None
return _Diff(text.splitlines(), [])

try:
oldtext = [rv["*"] for rv in revs if rv["revid"] == int(oldrev)][0]
newtext = [rv["*"] for rv in revs if rv["revid"] == int(newrev)][0]
oldtext = [rv["slots"]["main"]["*"] for rv in revs
if rv["revid"] == int(oldrev)][0]
newtext = [rv["slots"]["main"]["*"] for rv in revs
if rv["revid"] == int(newrev)][0]
except (IndexError, KeyError):
return None



+ 4
- 2
tasks/afc_statistics.py Wyświetl plik

@@ -502,9 +502,11 @@ class AFCStatistics(Task):
if revid in self.revision_cache:
return self.revision_cache[revid]
res = self.site.api_query(action="query", prop="revisions",
revids=revid, rvprop="content")
rvprop="content", rvslots="main",
revids=revid)
try:
content = res["query"]["pages"].values()[0]["revisions"][0]["*"]
revision = res["query"]["pages"].values()[0]["revisions"][0]
content = revision["slots"]["main"]["*"]
except KeyError:
if tries == 0:
raise


+ 4
- 3
tasks/banner_untag.py Wyświetl plik

@@ -86,15 +86,16 @@ class BannerUntag(Task):
return

res2 = self.site.api_query(
action="query", prop="revisions", rvprop="content",
action="query", prop="revisions", rvprop="content", rvslots="main",
revids="|".join(stage2), formatversion=2)

for pagedata in res2["query"]["pages"]:
if pagedata["revisions"][0]["contentmodel"] != "wikitext":
revision = pagedata["revisions"][0]["slots"]["main"]
if revision["contentmodel"] != "wikitext":
continue
pageid = pagedata["pageid"]
title = pagedata["title"]
content = pagedata["revisions"][0]["content"]
content = revision["content"]

self.logger.debug(u"Reverting one edit on [[%s]]" % title)
page = self.site.get_page(title)


Ładowanie…
Anuluj
Zapisz