Source code for pywikibot.specialbots._unlink

#!/usr/bin/python
"""Special bot library containing BaseUnlinkBot.

Do not import classes directly from here but from specialbots.
"""
#
# (C) Pywikibot team, 2003-2021
#
# Distributed under the terms of the MIT license.
#
from pywikibot.bot import (
    AlwaysChoice,
    AutomaticTWSummaryBot,
    ChoiceException,
    ExistingPageBot,
    InteractiveReplace,
    NoRedirectPageBot,
)
from pywikibot.editor import TextEditor
from pywikibot.bot_choice import UnhandledAnswer
from pywikibot.textlib import replace_links
from pywikibot.tools import ModuleDeprecationWrapper


class EditReplacementError(ChoiceException, UnhandledAnswer):

    """The text should be edited and replacement should be restarted."""

    def __init__(self):
        """Initializer."""
        super().__init__('edit', 'e')
        self.stop = True





[docs]class BaseUnlinkBot(ExistingPageBot, NoRedirectPageBot, AutomaticTWSummaryBot): """A basic bot unlinking a given link from the current page.""" def __init__(self, **kwargs): """Redirect all parameters and add namespace as an available option.""" self.available_options.update({ 'namespaces': [], # Which namespaces should be processed? # default to [] which means all namespaces will be processed }) super().__init__(**kwargs) def _create_callback(self): """Create a new callback instance for replace_links.""" return InteractiveUnlink(self)
EditReplacement = EditReplacementError wrapper = ModuleDeprecationWrapper(__name__) wrapper.add_deprecated_attr( 'EditReplacement', replacement_name='EditReplacementError', since='20210423')