Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1275263?usp=email )
Change subject: IMPR: load allpages with content flag
......................................................................
IMPR: load allpages with content flag
Also show a dot after every 100 processed pages.
Bug: T423836
Change-Id: I150d24b8f779f5caeae5346b5c27922aaf4aee79
---
M scripts/parser_function_count.py
1 file changed, 8 insertions(+), 11 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/scripts/parser_function_count.py b/scripts/parser_function_count.py
index 6c74556..9296ae4 100755
--- a/scripts/parser_function_count.py
+++ b/scripts/parser_function_count.py
@@ -116,8 +116,8 @@
@property
def generator(self):
"""Generator."""
- gen = self.site.allpages(start=self.opt.start,
- namespace=10, filterredir=False)
+ gen = self.site.allpages(start=self.opt.start, namespace=10,
+ filterredir=False, content=True)
if self.site.doc_subpage:
gen = pagegenerators.RegexFilterPageGenerator(
gen, self.site.doc_subpage, quantifier='none')
@@ -125,8 +125,7 @@
def setup(self) -> None:
"""Setup magic words, regex and result counter."""
- pywikibot.info('Hold on, this will need some time. '
- 'You will be notified by 50 templates.')
+ pywikibot.info('Hold on, this will need some time.')
magicwords = []
for magic_word in self.site.siteinfo['magicwords']:
magicwords += magic_word['aliases']
@@ -135,17 +134,14 @@
def treat(self, page) -> None:
"""Process a single template."""
- title = page.title()
- if (self.counter['read'] + 1) % 50 == 0:
+ if self.counter['read'] % 100 == 0:
# Don't let the poor user panic in front of a black screen.
- pywikibot.info('{}th template is being processed: {}'
- .format(self.counter['read'] + 1, title))
+ pywikibot.info('.', newline=False)
- text = page.text
- functions = self.regex.findall(text)
+ functions = self.regex.findall(page.text)
if functions and (self.opt.atleast is None
or self.opt.atleast <= len(functions)):
- self.results[title] = len(functions)
+ self.results[page.title()] = len(functions)
if self.opt.nosort and self.opt.first \
and len(self.results) >= self.opt.first:
@@ -157,6 +153,7 @@
f'# [[{result[0]}]] ({result[1]})'
for result in self.results.most_common(self.opt.first))
+ pywikibot.info()
pywikibot.info(resultlist)
pywikibot.info(f'{len(self.results)} templates were found.')
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1275263?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: I150d24b8f779f5caeae5346b5c27922aaf4aee79
Gerrit-Change-Number: 1275263
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[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]