jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340527?usp=email )
Change subject: Reuse the hostname in the Google page generator
......................................................................
Reuse the hostname in the Google page generator
Read the site's hostname once and reuse it in the search query and URL
matching pattern. Avoid the duplicate hostname() call during generator
initialization.
Change-Id: Ib5809c661066370320854cbd825b678f3a5a0123
---
M pywikibot/pagegenerators/_generators.py
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators/_generators.py
b/pywikibot/pagegenerators/_generators.py
index 3ae65d8..3456f6a 100644
--- a/pywikibot/pagegenerators/_generators.py
+++ b/pywikibot/pagegenerators/_generators.py
@@ -998,8 +998,9 @@
# restrict query to local site
site = self.site
- local_query = f'{self.query} site:{site.hostname()}'
- base = f'{site.protocol()}://{site.hostname()}{site.articlepath}'
+ hostname = site.hostname()
+ local_query = f'{self.query} site:{hostname}'
+ base = f'{site.protocol()}://{hostname}{site.articlepath}'
pattern = re.compile(base.replace('{}', '(?P<title>.+)'))
for url in self.queryGoogle(local_query, num_results=self.limit,
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340527?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: Ib5809c661066370320854cbd825b678f3a5a0123
Gerrit-Change-Number: 1340527
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]