Pārlūkot izejas kodu

Log warnings; use rvslots when fetching revision content

tags/v0.3
Ben Kurtovic pirms 5 gadiem
vecāks
revīzija
f1b93a465a
3 mainītis faili ar 23 papildinājumiem un 7 dzēšanām
  1. +4
    -1
      CHANGELOG
  2. +7
    -5
      earwigbot/wiki/page.py
  3. +12
    -1
      earwigbot/wiki/site.py

+ 4
- 1
CHANGELOG Parādīt failu

@@ -1,7 +1,8 @@
v0.3 (unreleased):

- Added various new features to the WikiProjectTagger task.
- Copyvio detector: improved sentence splitting algorithm.
- Copyvio detector: improved sentence splitting algorithm; many performance
improvements.
- Improved config file command/task exclusion logic.
- IRC > !cidr: Added; new command for calculating range blocks.
- IRC > !notes: Improved help and added aliases.
@@ -13,6 +14,8 @@ v0.3 (unreleased):
- IRC: Try not to join channels before NickServ auth has completed.
- IRC: Improved detection of maximum IRC message length.
- IRC: Improved some help commands.
- Wiki: Added logging for warnings.
- Wiki: Updated some deprecated API calls.
- Wiki: Fixed Page.toggle_talk() behavior on mainspace titles with colons.

v0.2 (released November 8, 2015):


+ 7
- 5
earwigbot/wiki/page.py Parādīt failu

@@ -264,13 +264,15 @@ class Page(CopyvioMixIn):
if not result:
query = self.site.api_query
result = query(action="query", prop="revisions", rvlimit=1,
rvprop="content|timestamp", titles=self._title)
rvprop="content|timestamp", rvslots="main",
titles=self._title)

res = result["query"]["pages"].values()[0]
try:
self._content = res["revisions"][0]["*"]
self._basetimestamp = res["revisions"][0]["timestamp"]
except KeyError:
revision = res["revisions"][0]
self._content = revision["slots"]["main"]["*"]
self._basetimestamp = revision["timestamp"]
except (KeyError, IndexError):
# This can only happen if the page was deleted since we last called
# self._load_attributes(). In that case, some of our attributes are
# outdated, so force another self._load_attributes():
@@ -582,7 +584,7 @@ class Page(CopyvioMixIn):
query = self.site.api_query
result = query(action="query", rvlimit=1, titles=self._title,
prop="info|revisions", inprop="protection|url",
rvprop="content|timestamp")
rvprop="content|timestamp", rvslots="main")
self._load_attributes(result=result)
self._assert_existence()
self._load_content(result=result)


+ 12
- 1
earwigbot/wiki/site.py Parādīt failu

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2009-2017 Ben Kurtovic <ben.kurtovic@gmail.com>
# Copyright (C) 2009-2019 Ben Kurtovic <ben.kurtovic@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -298,6 +298,17 @@ class Site(object):
e = "API query failed: JSON could not be decoded."
raise exceptions.APIError(e)

if "warnings" in res:
for name, value in res["warnings"].items():
try:
warning = value["warnings"]
except KeyError:
try:
warning = value["*"]
except KeyError:
warning = value
self._logger.warning("API warning: %s: %s", name, warning)

try:
code = res["error"]["code"]
info = res["error"]["info"]


Notiek ielāde…
Atcelt
Saglabāt