jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
Remove BasePage._namespace_obj

According to T104864, the issue with namespace method is resolved.
_namespace_obj has been a temporary workaround for that issue.
Remove _namespace_obj and correct the return types of Page.namespace
and Link.namespace.

Bug: T104864
Change-Id: I97c4340dbfd11ca9dcc35a0f1db2ca7c79e0f829
---
M pywikibot/page.py
M scripts/interwiki.py
2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/pywikibot/page.py b/pywikibot/page.py
index 6054c3c..b75002e 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -241,17 +241,11 @@
Return the number of the namespace of the page.

@return: namespace of the page
- @rtype: int
+ @rtype: Namespace
"""
return self._link.namespace

@property
- def _namespace_obj(self):
- """Return the namespace object of the page."""
- # TODO: T104864: Temporary until Page.namespace() is consistent
- return self.site.namespaces[self.namespace()]
-
- @property
def content_model(self):
"""
Return the content model for this page.
@@ -269,7 +263,7 @@
"""Return the depth/subpage level of the page."""
if not hasattr(self, '_depth'):
# Check if the namespace allows subpages
- if self._namespace_obj.subpages:
+ if self.namespace().subpages:
self._depth = self.title().count('/')
else:
# Does not allow subpages, which means depth is always 0
@@ -5692,7 +5686,7 @@
"""
Return the namespace of the link.

- @rtype: unicode
+ @rtype: Namespace
"""
if not hasattr(self, "_namespace"):
self.parse()
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index b36175f..f11ad05 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2367,7 +2367,7 @@
@rtype: bool
"""
# Check if the page is in content namespace
- if page._namespace_obj.content:
+ if page.namespace().content:
# Check if the page contains at least 50 characters
return len(page.text) < 50
else:

To view, visit change 444786. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I97c4340dbfd11ca9dcc35a0f1db2ca7c79e0f829
Gerrit-Change-Number: 444786
Gerrit-PatchSet: 1
Gerrit-Owner: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot