jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/691490 )
Change subject: [choice] Rename UnhandledAnswerError back to UnhandledAnswer
......................................................................
[choice] Rename UnhandledAnswerError back to UnhandledAnswer
UnhandledAnswer is not pywikibot.Error rather than a ChoiceException
like QuitKeyboardInterrupt. Move it to bot_choice module.
Change-Id: I2d017f0165342958b51a2b48694a9421be1493ac
---
M pywikibot/bot.py
M pywikibot/bot_choice.py
M pywikibot/exceptions.py
M pywikibot/specialbots/_unlink.py
4 files changed, 16 insertions(+), 29 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index e1bc0e3..1e2b431 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -66,7 +66,7 @@
'Option', 'StandardOption', 'NestedOption',
'IntegerOption',
'ContextOption', 'ListOption', 'ShowingListOption',
'MultipleChoiceList',
'ShowingMultipleChoiceList', 'OutputProxyOption',
- 'HighlightContextOption', 'ChoiceException',
'UnhandledAnswerError',
+ 'HighlightContextOption', 'ChoiceException',
'UnhandledAnswer',
'Choice', 'StaticChoice', 'LinkChoice',
'AlwaysChoice',
'QuitKeyboardInterrupt',
'InteractiveReplace',
@@ -122,6 +122,7 @@
ShowingMultipleChoiceList,
StandardOption,
StaticChoice,
+ UnhandledAnswer,
)
from pywikibot.exceptions import (
EditConflictError,
@@ -131,7 +132,6 @@
PageSaveRelatedError,
ServerError,
SpamblacklistError,
- UnhandledAnswerError,
UnknownFamilyError,
UnknownSiteError,
VersionParseError,
@@ -158,7 +158,6 @@
)
from pywikibot.tools import (
PYTHON_VERSION,
- ModuleDeprecationWrapper,
deprecate_arg,
deprecated,
deprecated_args,
@@ -655,7 +654,7 @@
while True:
try:
answer = self.handle_link()
- except UnhandledAnswerError as e:
+ except UnhandledAnswer as e:
if e.stop:
raise
else:
@@ -2271,13 +2270,3 @@
raise NotImplementedError('Method {}.treat_page_and_item() not '
'implemented.'
.format(self.__class__.__name__))
-
-
-UnhandledAnswer = UnhandledAnswerError
-
-wrapper = ModuleDeprecationWrapper(__name__)
-wrapper._add_deprecated_attr(
- 'UnhandledAnswer',
- replacement_name='pywikibot.exceptions.UnhandledAnswerError',
- since='20210423',
- future_warning=True)
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index 4f2abe9..5385947 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -1,6 +1,6 @@
"""Choices for input_choice."""
#
-# (C) Pywikibot team, 2015-2020
+# (C) Pywikibot team, 2015-2021
#
# Distributed under the terms of the MIT license.
#
@@ -508,6 +508,15 @@
+ self.text[self.end:end])
+class UnhandledAnswer(Exception):
+
+ """The given answer didn't suffice."""
+
+ def __int__(self, stop=False):
+ """Initializer."""
+ self.stop = stop
+
+
class ChoiceException(StandardOption, Exception):
"""A choice for input_choice which result in this
exception."""
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index a68cdaa..290cc4c 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -51,7 +51,6 @@
+-- TranslationError
+-- UserRightsError
| +-- HiddenKeyError (KeyError)
- +-- UnhandledAnswerError
+-- UnknownExtensionError (NotImplementedError)
+-- VersionParseError
+-- WikiBaseError
@@ -77,7 +76,6 @@
- CaptchaError: Captcha is asked and config.solve_captcha == False
- i18n.TranslationError: i18n/l10n message not available
- PageInUseError: Page cannot be reserved due to a lock
- - UnhandledAnswerError: bot choice caused a problem to arise
- UnknownExtensionError: Extension is not defined for this site
- VersionParseError: failed to parse version information
- SectionError: The section specified by # does not exist
@@ -614,15 +612,6 @@
"""
-class UnhandledAnswerError(Error):
-
- """The given answer didn't suffice."""
-
- def __init__(self, stop=False):
- """Initializer."""
- self.stop = stop
-
-
class TranslationError(Error, ImportError):
"""Raised when no correct translation could be found.
diff --git a/pywikibot/specialbots/_unlink.py b/pywikibot/specialbots/_unlink.py
index cc50250..aa3e105 100644
--- a/pywikibot/specialbots/_unlink.py
+++ b/pywikibot/specialbots/_unlink.py
@@ -4,7 +4,7 @@
Do not import classes directly from here but from specialbots.
"""
#
-# (C) Pywikibot team, 2003-2020
+# (C) Pywikibot team, 2003-2021
#
# Distributed under the terms of the MIT license.
#
@@ -17,12 +17,12 @@
NoRedirectPageBot,
)
from pywikibot.editor import TextEditor
-from pywikibot.exceptions import UnhandledAnswerError
+from pywikibot.bot_choice import UnhandledAnswer
from pywikibot.textlib import replace_links
from pywikibot.tools import ModuleDeprecationWrapper
-class EditReplacementError(ChoiceException, UnhandledAnswerError):
+class EditReplacementError(ChoiceException, UnhandledAnswer):
"""The text should be edited and replacement should be
restarted."""
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/691490
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2d017f0165342958b51a2b48694a9421be1493ac
Gerrit-Change-Number: 691490
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged