jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/661712 )
Change subject: [IMPR] move ClosedSite and RemovedSite to _obsoletesites.py
......................................................................
[IMPR] move ClosedSite and RemovedSite to _obsoletesites.py
Change-Id: I0d284c1c1ecbac8e122f2682f68bea3bb74b9b1e
---
M docs/api_ref/pywikibot.site.rst
M pywikibot/CONTENT.rst
M pywikibot/site/__init__.py
M pywikibot/site/_apisite.py
M pywikibot/site/_basesite.py
A pywikibot/site/_obsoletesites.py
6 files changed, 79 insertions(+), 59 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/api_ref/pywikibot.site.rst b/docs/api_ref/pywikibot.site.rst
index 8fe4299..16f44a2 100644
--- a/docs/api_ref/pywikibot.site.rst
+++ b/docs/api_ref/pywikibot.site.rst
@@ -31,6 +31,11 @@
.. automodule:: pywikibot._namespace
+pywikibot.site.\_obsoletesites module
+-------------------------------------
+
+.. automodule:: pywikibot.site._obsoletesites
+
pywikibot.site.\_siteinfo module
--------------------------------
diff --git a/pywikibot/CONTENT.rst b/pywikibot/CONTENT.rst
index d158d1d..4dd9fde 100644
--- a/pywikibot/CONTENT.rst
+++ b/pywikibot/CONTENT.rst
@@ -124,6 +124,8 @@
+----------------------------+------------------------------------------------------+
| _namespace.py | Objects representing Namespaces of
MediaWiki site |
+----------------------------+------------------------------------------------------+
+ | _obsoletesites.py | Objects representing obsolete MediaWiki
sites |
+
+----------------------------+------------------------------------------------------+
| _siteinfo.py | Objects representing site info data
contents |
+----------------------------+------------------------------------------------------+
| _tokenwallet.py | Objects representing api tokens
|
diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py
index 5a74082..101e26a 100644
--- a/pywikibot/site/__init__.py
+++ b/pywikibot/site/__init__.py
@@ -5,9 +5,10 @@
#
# Distributed under the terms of the MIT license.
#
-from pywikibot.site._apisite import APISite, ClosedSite, DataSite
-from pywikibot.site._basesite import BaseSite, PageInUse, RemovedSite
+from pywikibot.site._apisite import APISite, DataSite
+from pywikibot.site._basesite import BaseSite, PageInUse
from pywikibot.site._namespace import Namespace, NamespacesDict
+from pywikibot.site._obsoletesites import ClosedSite, RemovedSite
from pywikibot.site._siteinfo import Siteinfo
from pywikibot.site._tokenwallet import TokenWallet
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 0767a30..cc01484 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -79,7 +79,7 @@
)
-__all__ = ('APISite', 'ClosedSite', 'DataSite')
+__all__ = ('APISite', 'DataSite')
_logger = 'wiki.apisite'
@@ -5741,54 +5741,6 @@
return data['shortenurl']['shorturl']
-class ClosedSite(APISite):
- """Site closed to read-only mode."""
-
- @remove_last_args(['sysop'])
- def __init__(self, code, fam, user=None):
- """Initializer."""
- super().__init__(code, fam, user)
-
- def _closed_error(self, notice=''):
- """An error instead of pointless API call."""
- pywikibot.error('Site {} has been closed. {}'.format(self.sitename,
- notice))
-
- def page_restrictions(self, page):
- """Return a dictionary reflecting page protections."""
- if not self.page_exists(page):
- raise NoPage(page)
- if not hasattr(page, '_protection'):
- page._protection = {'edit': ('steward', 'infinity'),
- 'move': ('steward', 'infinity'),
- 'delete': ('steward', 'infinity'),
- 'upload': ('steward', 'infinity'),
- 'create': ('steward', 'infinity')}
- return page._protection
-
- def recentchanges(self, **kwargs):
- """An error instead of pointless API call."""
- self._closed_error('No recent changes can be returned.')
-
- def is_uploaddisabled(self):
- """Return True if upload is disabled on site."""
- if not hasattr(self, '_uploaddisabled'):
- self._uploaddisabled = True
- return self._uploaddisabled
-
- def newpages(self, **kwargs):
- """An error instead of pointless API call."""
- self._closed_error('No new pages can be returned.')
-
- def newfiles(self, **kwargs):
- """An error instead of pointless API call."""
- self._closed_error('No new files can be returned.')
-
- def newimages(self, *args, **kwargs):
- """An error instead of pointless API call."""
- self._closed_error('No new images can be returned.')
-
-
class DataSite(APISite):
"""Wikibase data capable site."""
diff --git a/pywikibot/site/_basesite.py b/pywikibot/site/_basesite.py
index 7e88701..e866e06 100644
--- a/pywikibot/site/_basesite.py
+++ b/pywikibot/site/_basesite.py
@@ -1,6 +1,6 @@
"""Objects with site methods independent of the communication interface."""
#
-# (C) Pywikibot team, 2008-2020
+# (C) Pywikibot team, 2008-2021
#
# Distributed under the terms of the MIT license.
#
@@ -476,10 +476,3 @@
def getSite(self, code): # noqa: N802
"""Return Site object for language 'code' in this Family."""
return pywikibot.Site(code=code, fam=self.family, user=self.user())
-
-
-class RemovedSite(BaseSite):
-
- """Site removed from a family."""
-
- pass
diff --git a/pywikibot/site/_obsoletesites.py b/pywikibot/site/_obsoletesites.py
new file mode 100644
index 0000000..e871def
--- /dev/null
+++ b/pywikibot/site/_obsoletesites.py
@@ -0,0 +1,67 @@
+"""Objects representing obsolete MediaWiki sites."""
+#
+# (C) Pywikibot team, 2019-2021
+#
+# Distributed under the terms of the MIT license.
+#
+import pywikibot
+
+from pywikibot.exceptions import NoPage
+from pywikibot.site._apisite import APISite
+from pywikibot.site._basesite import BaseSite
+from pywikibot.tools import remove_last_args
+
+
+class RemovedSite(BaseSite):
+
+ """Site removed from a family."""
+
+ pass
+
+
+class ClosedSite(APISite):
+ """Site closed to read-only mode."""
+
+ @remove_last_args(['sysop'])
+ def __init__(self, code, fam, user=None):
+ """Initializer."""
+ super().__init__(code, fam, user)
+
+ def _closed_error(self, notice=''):
+ """An error instead of pointless API call."""
+ pywikibot.error('Site {} has been closed. {}'.format(self.sitename,
+ notice))
+
+ def page_restrictions(self, page):
+ """Return a dictionary reflecting page protections."""
+ if not self.page_exists(page):
+ raise NoPage(page)
+ if not hasattr(page, '_protection'):
+ page._protection = {'edit': ('steward', 'infinity'),
+ 'move': ('steward', 'infinity'),
+ 'delete': ('steward', 'infinity'),
+ 'upload': ('steward', 'infinity'),
+ 'create': ('steward', 'infinity')}
+ return page._protection
+
+ def recentchanges(self, **kwargs):
+ """An error instead of pointless API call."""
+ self._closed_error('No recent changes can be returned.')
+
+ def is_uploaddisabled(self):
+ """Return True if upload is disabled on site."""
+ if not hasattr(self, '_uploaddisabled'):
+ self._uploaddisabled = True
+ return self._uploaddisabled
+
+ def newpages(self, **kwargs):
+ """An error instead of pointless API call."""
+ self._closed_error('No new pages can be returned.')
+
+ def newfiles(self, **kwargs):
+ """An error instead of pointless API call."""
+ self._closed_error('No new files can be returned.')
+
+ def newimages(self, *args, **kwargs):
+ """An error instead of pointless API call."""
+ self._closed_error('No new images can be returned.')
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/661712
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: I0d284c1c1ecbac8e122f2682f68bea3bb74b9b1e
Gerrit-Change-Number: 661712
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits