Source code for pywikibot.site._obsoletesites

"""Objects representing obsolete MediaWiki sites."""
#
# (C) Pywikibot team, 2019-2022
#
# Distributed under the terms of the MIT license.
#
import pywikibot
from pywikibot.backports import Dict, Tuple
from pywikibot.exceptions import NoPageError
from pywikibot.site._apisite import APISite
from pywikibot.site._basesite import BaseSite


[docs]class RemovedSite(BaseSite): """Site removed from a family."""
[docs]class ClosedSite(APISite): """Site closed to read-only mode.""" def _closed_error(self, notice: str = '') -> None: """An error instead of pointless API call.""" pywikibot.error('Site {} has been closed. {}'.format(self.sitename, notice))
[docs] def page_restrictions( self, page: 'pywikibot.Page') -> Dict[str, Tuple[str, str]]: """Return a dictionary reflecting page protections.""" if not page.exists(): raise NoPageError(page) if not hasattr(page, '_protection'): page._protection = dict.fromkeys( ('create', 'delete', 'edit', 'move', 'upload'), ('steward', 'infinity')) return page._protection
[docs] def recentchanges(self, **kwargs) -> None: """An error instead of pointless API call.""" self._closed_error('No recent changes can be returned.')
[docs] def is_uploaddisabled(self) -> bool: """Upload is disabled on site.""" return True
[docs] def newpages(self, **kwargs) -> None: """An error instead of pointless API call.""" self._closed_error('No new pages can be returned.')