jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/449026 )
Change subject: [cleanup] Remove getParsedString Site method
......................................................................
[cleanup] Remove getParsedString Site method
getParsedString Site method was never part of the
rewrite/core release. The method does just return
a NotImplementedError.
Remove this part of code after this long time (since 25.12.14),
because it seems better to raise an attribute error instead of
having a wrong behaviour for old scripts.
Bug: T106121
Change-Id: I5ecb59ec0b7a41b59ee6528ab3bc75954d580a72
---
M pywikibot/site.py
1 file changed, 0 insertions(+), 7 deletions(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 81f6b2b..49db849 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3600,13 +3600,6 @@
self.username(sysop), self.user()))
return self.tokens['patrol']
- def getParsedString(self, string, keeptags=None):
- """Deprecated.
-
- compat defined keeptags as ['*'].
- """
- return NotImplementedError
-
# following group of methods map more-or-less directly to API queries
@deprecated_args(
--
To view, visit https://gerrit.wikimedia.org/r/449026
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5ecb59ec0b7a41b59ee6528ab3bc75954d580a72
Gerrit-Change-Number: 449026
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/449027 )
Change subject: Update all Page.title calls to not use deprecated parameter names
......................................................................
Update all Page.title calls to not use deprecated parameter names
Change-Id: Iac57c299ccd09aecdbbf3a2395db31a971921126
---
M README-conversion.txt
M pywikibot/page.py
M scripts/checkimages.py
M scripts/interwikidata.py
M scripts/maintenance/compat2core.py
M scripts/patrol.py
M scripts/redirect.py
M tests/category_tests.py
8 files changed, 30 insertions(+), 30 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/README-conversion.txt b/README-conversion.txt
index b033f65..4363efa 100644
--- a/README-conversion.txt
+++ b/README-conversion.txt
@@ -72,10 +72,10 @@
The following methods of the Page object have been deprecated (deprecated
methods still work, but print a warning message in debug mode):
-- urlname(): replaced by Page.title(asUrl=True)
-- titleWithoutNamespace(): replaced by Page.title(withNamespace=False)
-- sectionFreeTitle(): replaced by Page.title(withSection=False)
-- aslink(): replaced by Page.title(asLink=True)
+- urlname(): replaced by Page.title(as_url=True)
+- titleWithoutNamespace(): replaced by Page.title(with_ns=False)
+- sectionFreeTitle(): replaced by Page.title(with_section=False)
+- aslink(): replaced by Page.title(as_link=True)
- encoding(): replaced by Page.site.encoding()
- put_async(): replaced by Page.put(asynchronous=True)
diff --git a/pywikibot/page.py b/pywikibot/page.py
index df0de1d..25ba43f 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -294,24 +294,24 @@
"""
Return the title of this Page, as a Unicode string.
- @param underscore: (not used with asLink) if true, replace all ' '
+ @param underscore: (not used with as_link) if true, replace all ' '
characters with '_'
@param with_ns: if false, omit the namespace prefix. If this
- option is false and used together with asLink return a labeled
+ option is false and used together with as_link return a labeled
link like [[link|label]]
@param with_section: if false, omit the section
- @param as_url: (not used with asLink) if true, quote title as if in an
+ @param as_url: (not used with as_link) if true, quote title as if in an
URL
@param as_link: if true, return the title in the form of a wikilink
- @param allow_interwiki: (only used if asLink is true) if true, format
+ @param allow_interwiki: (only used if as_link is true) if true, format
the link as an interwiki link if necessary
- @param force_interwiki: (only used if asLink is true) if true, always
+ @param force_interwiki: (only used if as_link is true) if true, always
format the link as an interwiki link
- @param textlink: (only used if asLink is true) if true, place a ':'
+ @param textlink: (only used if as_link is true) if true, place a ':'
before Category: and Image: links
- @param as_filename: (not used with asLink) if true, replace any
+ @param as_filename: (not used with as_link) if true, replace any
characters that are unsafe in filenames
- @param insite: (only used if asLink is true) a site object where the
+ @param insite: (only used if as_link is true) a site object where the
title is to be shown. default is the current family/lang given by
-family and -lang option i.e. config.family and config.mylang
@rtype: unicode
@@ -2686,7 +2686,7 @@
Download to filename file of FilePage.
@param filename: filename where to save file:
- None: self.title(as_filename=True, withNamespace=False)
+ None: self.title(as_filename=True, with_ns=False)
will be used
str: provided filename will be used.
@type filename: None or str
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 102ecc1..ccb3010 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -876,9 +876,9 @@
"is also on '''Commons''': [[commons:File:%s]]")
% (self.imageName,
commons_image_with_this_hash.title(
- withNamespace=False)))
+ with_ns=False)))
if (self.image.title(as_url=True) ==
- commons_image_with_this_hash.title(asUrl=True)):
+ commons_image_with_this_hash.title(as_url=True)):
repme += ' (same name)'
self.report_image(self.imageName, self.rep_page, self.com, repme,
addings=False)
diff --git a/scripts/interwikidata.py b/scripts/interwikidata.py
index d386574..9e06001 100644
--- a/scripts/interwikidata.py
+++ b/scripts/interwikidata.py
@@ -183,7 +183,7 @@
item = list(wd_data).pop()
if self.current_page.site.dbName() in item.sitelinks:
warning('Interwiki conflict in %s, skipping...' %
- item.title(asLink=True))
+ item.title(as_link=True))
return False
output('Adding link to %s' % item.title())
item.setSitelink(self.current_page, summary='Added %s' % (
diff --git a/scripts/maintenance/compat2core.py b/scripts/maintenance/compat2core.py
index e0964f5..8ec31c7 100755
--- a/scripts/maintenance/compat2core.py
+++ b/scripts/maintenance/compat2core.py
@@ -69,12 +69,12 @@
# change ImagePage to FilePage
(r'pywikibot\.ImagePage\s*\(\s*', 'pywikibot.FilePage('),
# deprecated title methods
- (r'\.urlname\s*\(\s*\)', '.title(asUrl=True)'),
+ (r'\.urlname\s*\(\s*\)', '.title(as_url=True)'),
(r'\.urlname\s*\(\s*(?:withNamespace\s*=\s*)?(True|False)+\s*\)',
- r'.title(asUrl=True, withNamespace=\1)'),
- (r'\.titleWithoutNamespace\s*\(\s*\)', '.title(withNamespace=False)'),
- (r'\.sectionFreeTitle\s*\(\s*\)', '.title(withSection=False)'),
- (r'\.aslink\s*\(\s*\)', '.title(asLink=True)'),
+ r'.title(as_url=True, with_ns=\1)'),
+ (r'\.titleWithoutNamespace\s*\(\s*\)', '.title(with_ns=False)'),
+ (r'\.sectionFreeTitle\s*\(\s*\)', '.title(with_section=False)'),
+ (r'\.aslink\s*\(\s*\)', '.title(as_link=True)'),
# other deprecated methods
(r'(?<!site)\.encoding\s*\(\s*\)', '.site.encoding()'),
(r'\.newimages\s*\(\)', ".logevents(logtype='upload')"),
diff --git a/scripts/patrol.py b/scripts/patrol.py
index 0e4cb92..7ef328f 100755
--- a/scripts/patrol.py
+++ b/scripts/patrol.py
@@ -373,10 +373,10 @@
except pywikibot.NoPage:
pywikibot.output(u'Page %s does not exist; skipping.'
- % title(asLink=True))
+ % title(as_link=True))
except pywikibot.IsRedirectPage:
pywikibot.output(u'Page %s is a redirect; skipping.'
- % title(asLink=True))
+ % title(as_link=True))
def title_match(prefix, title):
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 1324f6d..a7c3f86 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -528,7 +528,7 @@
reason = i18n.twtranslate(self.site,
'redirect-fix-broken-moved',
{'to': movedTarget.title(
- asLink=True)})
+ as_link=True)})
content = redir_page.get(get_redirect=True)
redir_page.set_redirect_target(
movedTarget, keep_section=True, save=False)
@@ -581,20 +581,20 @@
redirList = [] # bookkeeping to detect loops
while True:
redirList.append(u'%s:%s' % (newRedir.site.lang,
- newRedir.title(withSection=False)))
+ newRedir.title(with_section=False)))
try:
targetPage = newRedir.getRedirectTarget()
except pywikibot.IsNotRedirectPage:
if len(redirList) == 2:
pywikibot.output(
u'Skipping: Redirect target %s is not a redirect.'
- % newRedir.title(asLink=True))
+ % newRedir.title(as_link=True))
break # do nothing
# else target found
except pywikibot.SectionError:
pywikibot.warning(
u"Redirect target section %s doesn't exist."
- % newRedir.title(asLink=True))
+ % newRedir.title(as_link=True))
except (pywikibot.CircularRedirect,
pywikibot.InterwikiRedirectPage,
pywikibot.UnsupportedPage) as e:
@@ -611,12 +611,12 @@
if self.getOption('always'):
pywikibot.output(
"Skipping: Redirect target {} doesn't exist."
- .format(newRedir.title(asLink=True)))
+ .format(newRedir.title(as_link=True)))
break # skip if automatic
else:
pywikibot.warning(
"Redirect target {} doesn't exist."
- .format(newRedir.title(asLink=True)))
+ .format(newRedir.title(as_link=True)))
except pywikibot.ServerError:
pywikibot.output(u'Skipping due to server error: '
u'No textarea found')
diff --git a/tests/category_tests.py b/tests/category_tests.py
index faf39b6..ae2bd4f 100644
--- a/tests/category_tests.py
+++ b/tests/category_tests.py
@@ -196,7 +196,7 @@
self.assertEqual(cat2.section(), None)
def test_aslink(self):
- """Test the title method with asLink=True."""
+ """Test the title method with as_link=True."""
site = self.get_site()
cat = pywikibot.Category(site, 'Category:Wikipedia Categories')
self.assertEqual(cat.title(as_link=True, insite=cat.site),
--
To view, visit https://gerrit.wikimedia.org/r/449027
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iac57c299ccd09aecdbbf3a2395db31a971921126
Gerrit-Change-Number: 449027
Gerrit-PatchSet: 1
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/448859 )
Change subject: proofreadpage.py: anticipate page filtering
......................................................................
proofreadpage.py: anticipate page filtering
Anticipate filtering on quality value and page existence,
in order to remove not-interesting pages earlier in the pipeline.
Change-Id: I08d5cd28a8470709c06a47686bb50cea8273c743
---
M pywikibot/proofreadpage.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 70304f1..348f67e 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -870,16 +870,16 @@
gen = (self.get_page(i) for i in range(start, end + 1))
if content:
gen = self.site.preloadpages(gen)
- # Decorate and sort by page number because preloadpages does not
- # guarantee order.
- # TODO: remove if preloadpages will guarantee order.
- gen = ((p, self.get_number(p)) for p in gen)
- gen = (p[0] for p in sorted(gen, key=lambda x: x[1]))
# Filter by QL.
gen = (p for p in gen if p.ql in filter_ql)
# Yield only existing.
if only_existing:
gen = (p for p in gen if p.exists())
+ # Decorate and sort by page number because preloadpages does not
+ # guarantee order.
+ # TODO: remove if preloadpages will guarantee order.
+ gen = ((p, self.get_number(p)) for p in gen)
+ gen = (p[0] for p in sorted(gen, key=lambda x: x[1]))
return gen
--
To view, visit https://gerrit.wikimedia.org/r/448859
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I08d5cd28a8470709c06a47686bb50cea8273c743
Gerrit-Change-Number: 448859
Gerrit-PatchSet: 3
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/447591 )
Change subject: Correctly handle invalid titles in harvest_template.py
......................................................................
Correctly handle invalid titles in harvest_template.py
Neither of those constructors raises that exception.
Bug: T200224
Change-Id: I002be74cd9590b06cb72df7c4e0476fb9ee9d76d
---
M scripts/harvest_template.py
1 file changed, 5 insertions(+), 4 deletions(-)
Approvals:
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index bef2894..b0ff2fd 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -182,14 +182,15 @@
def _template_link_target(self, item, link_text):
link = pywikibot.Link(link_text)
+ linked_page = pywikibot.Page(link)
try:
- linked_page = pywikibot.Page(link)
+ exists = linked_page.exists()
except pywikibot.exceptions.InvalidTitle:
- pywikibot.error('%s is not a valid title so it cannot be linked. '
- 'Skipping.' % link_text)
+ pywikibot.error('"%s" is not a valid title so it cannot be linked.'
+ ' Skipping.' % link_text)
return None
- if not linked_page.exists():
+ if not exists:
pywikibot.output('%s does not exist so it cannot be linked. '
'Skipping.' % (linked_page))
return None
--
To view, visit https://gerrit.wikimedia.org/r/447591
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I002be74cd9590b06cb72df7c4e0476fb9ee9d76d
Gerrit-Change-Number: 447591
Gerrit-PatchSet: 2
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)