jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326337?usp=email )
Change subject: wikibase: Reuse repository and page properties
......................................................................
wikibase: Reuse repository and page properties
Resolve the data repository once while creating an item from a page.
Reuse cached page properties when selecting an existing item ID.
Change-Id: Ibfe17f898f1ccd5c7c93b9998df46c950400cdb8
---
M pywikibot/page/_wikibase.py
1 file changed, 7 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py
index 105c484..7ab1c56 100644
--- a/pywikibot/page/_wikibase.py
+++ b/pywikibot/page/_wikibase.py
@@ -1073,18 +1073,19 @@
"""
if hasattr(page, '_item'):
return page._item
- if not page.site.has_data_repository:
+ repo = page.site.data_repository()
+ if repo is None:
raise WikiBaseError(f'{page.site} has no data repository')
if not lazy_load and not page.exists():
raise NoPageError(page)
- repo = page.site.data_repository()
- if hasattr(page,
- '_pageprops') and page.properties().get('wikibase_item'):
+ if hasattr(page, '_pageprops'):
# If we have already fetched the pageprops for something else,
# we already have the id, so use it
- page._item = cls(repo, page.properties().get('wikibase_item'))
- return page._item
+ item_id = page.properties().get('wikibase_item')
+ if item_id:
+ page._item = cls(repo, item_id)
+ return page._item
i = cls(repo)
# clear id, and temporarily store data needed to lazy loading the item
del i.id
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326337?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ibfe17f898f1ccd5c7c93b9998df46c950400cdb8
Gerrit-Change-Number: 1326337
Gerrit-PatchSet: 1
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]