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 ClosedSite(APISite):
"""Site closed to read-only mode."""
def _closed_error(self, notice: str = '') -> None:
"""An error instead of pointless API call."""
pywikibot.error(f'Site {self.sitename} has been closed. {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 newpages(self, **kwargs) -> None:
"""An error instead of pointless API call."""
self._closed_error('No new pages can be returned.')