jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/926808 )

Change subject: Correct terminology around NoSiteLinkError
......................................................................

Correct terminology around NoSiteLinkError

Sitelinks are unique per wiki, not necessarily by language.

Change-Id: I315a62a51e1b035ac6be97e6267e998f3ffc6f98
---
M pywikibot/exceptions.py
M pywikibot/page/_wikibase.py
2 files changed, 21 insertions(+), 7 deletions(-)

Approvals:
  Ammarpad: Looks good to me, but someone else must approve
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index cfe4601..e5c1a6a 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -107,7 +107,7 @@

 PageLoadRelatedError: any exception which happens while loading a Page.
   - InconsistentTitleError: Page receives a title inconsistent with query
-  - NoSiteLinkError: ItemPage has no sitelink to given language
+  - NoSiteLinkError: ItemPage has no sitelink to given site

 PageSaveRelatedError: page exceptions within the save operation on a Page

@@ -400,21 +400,21 @@

 class NoSiteLinkError(PageLoadRelatedError, NoPageError):

-    """ItemPage has no sitelink to the given language.
+    """ItemPage has no sitelink to the given site.

     .. versionadded:: 8.1
     .. deprecated:: 8.1
        :exc:`NoPageError` dependency.
     """

-    def __init__(self, page: 'pywikibot.page.ItemPage', lang: str) -> None:
+    def __init__(self, page: 'pywikibot.page.ItemPage', dbname: str) -> None:
         """Initializer.

         :param page: ItemPage that caused the exception
-        :param lang: language code of the queried sitelink
+        :param dbname: site identifier of the queried sitelink
 
         """
-        self.message = f'Item {{}} has no sitelink to language {lang!r}'
+        self.message = f'Item {{}} has no sitelink to {dbname!r}'
         super().__init__(page)


diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py
index d7e9f5c..2083a3c 100644
--- a/pywikibot/page/_wikibase.py
+++ b/pywikibot/page/_wikibase.py
@@ -1078,7 +1078,8 @@
     def getSitelink(self, site, force: bool = False) -> str:
         """Return the title for the specific site.

-        If the item doesn't have that language, raise NoSiteLinkError.
+        If the item doesn't have a link to that site, raise
+        NoSiteLinkError.

         .. versionchanged:: 8.1
            raises NoSiteLinkError instead of NoPageError.
@@ -1095,7 +1096,9 @@
             self.get(force=force)

         if site not in self.sitelinks:
-            raise NoSiteLinkError(self, site.lang)
+            if not isinstance(site, str):
+                site = site.dbName()
+            raise NoSiteLinkError(self, site)

         return self.sitelinks[site].canonical_title()


--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/926808
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: I315a62a51e1b035ac6be97e6267e998f3ffc6f98
Gerrit-Change-Number: 926808
Gerrit-PatchSet: 3
Gerrit-Owner: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Ammarpad <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to