jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/370182 )
Change subject: [doc] Give a hint how to use that script
......................................................................
[doc] Give a hint how to use that script
Change-Id: I7034faea524962f78c378c9a573add90b8fd738a
---
M scripts/maintenance/wikimedia_sites.py
1 file changed, 7 insertions(+), 1 deletion(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py
index 89db954..8f87d60 100755
--- a/scripts/maintenance/wikimedia_sites.py
+++ b/scripts/maintenance/wikimedia_sites.py
@@ -1,6 +1,12 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-"""Script that updates the language lists in Wikimedia family files."""
+"""Script that updates the language lists in Wikimedia family files.
+
+Usage:
+
+ python pwb.py wikimedia_sites [ {<family>} ]
+
+"""
#
# (C) xqt, 2009-2017
# (C) Pywikibot team, 2008-2017
--
To view, visit https://gerrit.wikimedia.org/r/370182
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7034faea524962f78c378c9a573add90b8fd738a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/369669 )
Change subject: [PEP8] Keep line length beneath 80 chars
......................................................................
[PEP8] Keep line length beneath 80 chars
Change-Id: I2fc59f971ed4b2418a135ad79be6573472825644
---
M scripts/pagefromfile.py
M scripts/patrol.py
M scripts/redirect.py
M scripts/replace.py
M scripts/replicate_wiki.py
M scripts/table2wiki.py
M scripts/welcome.py
7 files changed, 51 insertions(+), 35 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index f4e9341..36fb613 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -165,15 +165,15 @@
else:
above, below = pagecontents, contents
comment = comment_bottom
- pywikibot.output('Page {0} already exists, appending on {1}!'.format(
- title, self.getOption('append')[0]))
+ pywikibot.output('Page {0} already exists, appending on {1}!'
+ .format(title, self.getOption('append')[0]))
contents = above + separator + below
elif self.getOption('force'):
pywikibot.output(u"Page %s already exists, ***overwriting!"
% title)
comment = comment_force
else:
- pywikibot.output(u"Page %s already exists, not adding!" % title)
+ pywikibot.output('Page %s already exists, not adding!' % title)
return
else:
if self.getOption('autosummary'):
diff --git a/scripts/patrol.py b/scripts/patrol.py
index 14c24a7..bc3bdc9 100755
--- a/scripts/patrol.py
+++ b/scripts/patrol.py
@@ -183,7 +183,7 @@
for item in pagelist:
if pywikibot.config.verbose_output:
- pywikibot.output(u'checking against whitelist item = %s' % item)
+ pywikibot.output('checking against whitelist item = %s' % item)
if isinstance(item, LinkedPagesRule):
if pywikibot.config.verbose_output:
@@ -252,13 +252,14 @@
if not user or current_user == user:
if self.is_wikisource_author_page(page):
if pywikibot.config.verbose_output:
- pywikibot.output(u'Whitelist author: %s' % page)
+ pywikibot.output('Whitelist author: %s' % page)
page = LinkedPagesRule(page)
else:
if pywikibot.config.verbose_output:
pywikibot.output(u'Whitelist page: %s' % page)
if pywikibot.config.verbose_output:
- pywikibot.output('Adding {0}:{1}'.format(current_user, page))
+ pywikibot.output('Adding {0}:{1}'
+ .format(current_user, page))
whitelist[current_user].append(page)
elif pywikibot.config.verbose_output:
pywikibot.output(u'Discarding whitelist page for '
@@ -340,7 +341,8 @@
if self.getOption('ask'):
choice = pywikibot.input_yn(
- u'Do you want to mark page as patrolled?', automatic_quit=False)
+ 'Do you want to mark page as patrolled?',
+ automatic_quit=False)
# Patrol the page
if choice:
diff --git a/scripts/redirect.py b/scripts/redirect.py
index bd8ddec..86855f0 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -168,7 +168,8 @@
not in self.namespaces:
continue
if alsoGetPageTitles:
- pageTitles.add(space_to_underscore(pywikibot.Link(entry.title, self.site)))
+ pageTitles.add(space_to_underscore(pywikibot.Link(entry.title,
+ self.site)))
m = redirR.match(entry.text)
if m:
@@ -186,8 +187,9 @@
else:
if target_link.site != self.site:
pywikibot.output(
- u'NOTE: Ignoring {0} which is a redirect to '
- u'another site {1}.'.format(entry.title, target_link.site))
+ 'NOTE: Ignoring {0} which is a redirect to '
+ 'another site {1}.'
+ .format(entry.title, target_link.site))
target_link = None
# if the redirect does not link to another wiki
if target_link and target_link.title:
@@ -497,7 +499,7 @@
except pywikibot.IsNotRedirectPage:
pywikibot.output(u'%s is not a redirect.' % redir_page.title())
except pywikibot.CircularRedirect:
- pywikibot.output(u'%s is a circular redirect.' % redir_page.title())
+ pywikibot.output('%s is a circular redirect.' % redir_page.title())
except pywikibot.NoPage:
pywikibot.output(u'%s doesn\'t exist.' % redir_page.title())
except pywikibot.InvalidTitle:
@@ -565,7 +567,8 @@
redir_page.title(asLink=True))):
self.delete_redirect(redir_page, 'redirect-remove-broken')
elif not (self.getOption('delete') or movedTarget):
- pywikibot.output(u'Cannot fix or delete the broken redirect')
+ pywikibot.output(
+ 'Cannot fix or delete the broken redirect')
except pywikibot.IsRedirectPage:
pywikibot.output(
"Redirect target {0} is also a redirect! {1}".format(
@@ -671,7 +674,8 @@
# Delete the two redirects
# TODO: Check whether pages aren't vandalized
# and (maybe) do not have a version history
- self.delete_redirect(targetPage, 'redirect-remove-loop')
+ self.delete_redirect(targetPage,
+ 'redirect-remove-loop')
self.delete_redirect(redir, 'redirect-remove-loop')
break
else: # redirect target found
@@ -693,7 +697,8 @@
pywikibot.output('Fixing double item redirect')
redir.set_redirect_target(targetPage)
break
- redir.set_redirect_target(targetPage, keep_section=True, save=False)
+ redir.set_redirect_target(targetPage, keep_section=True,
+ save=False)
summary = i18n.twtranslate(self.site, 'redirect-fix-double',
{'to': targetPage.title(asLink=True)}
)
diff --git a/scripts/replace.py b/scripts/replace.py
index 7e32b7d..c1e7bcb 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -630,15 +630,15 @@
page.title(), replacement.exceptions):
if replacement.container:
pywikibot.output(
- 'Skipping fix "{0}" on {1} because the title is on the '
- 'exceptions list.'.format(
+ 'Skipping fix "{0}" on {1} because the title is on '
+ 'the exceptions list.'.format(
replacement.container.name,
page.title(asLink=True)))
skipped_containers.add(replacement.container.name)
else:
pywikibot.output(
- 'Skipping unnamed replacement ({0}) on {1} because the '
- 'title is on the exceptions list.'.format(
+ 'Skipping unnamed replacement ({0}) on {1} because '
+ 'the title is on the exceptions list.'.format(
replacement.description, page.title(asLink=True)))
continue
old_text = new_text
@@ -670,7 +670,8 @@
self.changed_pages += 1
self._pending_processed_titles.put((page.title(asLink=True), True))
else: # unsuccessful pages
- self._pending_processed_titles.put((page.title(asLink=True), False))
+ self._pending_processed_titles.put((page.title(asLink=True),
+ False))
def _replace_async_callback(self, page, err):
"""Callback for asynchronous page edit."""
@@ -727,7 +728,7 @@
% page.title(asLink=True))
continue
except pywikibot.NoPage:
- pywikibot.output(u'Page %s not found' % page.title(asLink=True))
+ pywikibot.output('Page %s not found' % page.title(asLink=True))
continue
applied = set()
new_text = original_text
@@ -749,8 +750,8 @@
% page.title(asLink=True))
break
if hasattr(self, 'addedCat'):
- # Fetch only categories in wikitext, otherwise the others will
- # be explicitly added.
+ # Fetch only categories in wikitext, otherwise the others
+ # will be explicitly added.
cats = textlib.getCategoryLinks(new_text, site=page.site)
if self.addedCat not in cats:
cats.append(self.addedCat)
@@ -766,7 +767,8 @@
break
choice = pywikibot.input_choice(
u'Do you want to accept these changes?',
- [('Yes', 'y'), ('No', 'n'), ('Edit original', 'e'), ('edit Latest', 'l'),
+ [('Yes', 'y'), ('No', 'n'), ('Edit original', 'e'),
+ ('edit Latest', 'l'),
('open in Browser', 'b'), ('all', 'a')],
default='N')
if choice == 'e':
@@ -782,7 +784,8 @@
# if user didn't press Cancel
if as_edited and as_edited != new_text:
new_text = as_edited
- last_text = new_text # prevent changes from being applied again
+ # prevent changes from being applied again
+ last_text = new_text
continue
if choice == 'b':
pywikibot.bot.open_webbrowser(page)
@@ -801,7 +804,8 @@
page.text = new_text
page.save(summary=self.generate_summary(applied),
asynchronous=True,
- callback=self._replace_async_callback, quiet=True)
+ callback=self._replace_async_callback,
+ quiet=True)
while not self._pending_processed_titles.empty():
proc_title, res = self._pending_processed_titles.get()
pywikibot.output('Page %s%s saved'
@@ -1010,7 +1014,7 @@
commandline_replacements.extend(file_replacements)
if not(commandline_replacements or fixes_set) or manual_input:
- old = pywikibot.input(u'Please enter the text that should be replaced:')
+ old = pywikibot.input('Please enter the text that should be replaced:')
while old:
new = pywikibot.input(u'Please enter the new text:')
commandline_replacements += [old, new]
@@ -1107,8 +1111,8 @@
% single_summary)
if missing_fixes_summaries:
pywikibot.output('The summary will not be used when the fix has '
- 'one defined but the following fix(es) do(es) not '
- 'have a summary defined: '
+ 'one defined but the following fix(es) do(es) '
+ 'not have a summary defined: '
'{0}'.format(', '.join(missing_fixes_summaries)))
if edit_summary is not True:
edit_summary = pywikibot.input(
@@ -1170,8 +1174,8 @@
site.login()
bot.run()
- # Explicitly call pywikibot.stopme().
- # It will make sure the callback is triggered before replace.py is unloaded.
+ # Explicitly call pywikibot.stopme(). It will make sure the callback is
+ # triggered before replace.py is unloaded.
pywikibot.stopme()
pywikibot.output(u'\n%s pages changed.' % bot.changed_pages)
diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py
index f2c0729..7009737 100755
--- a/scripts/replicate_wiki.py
+++ b/scripts/replicate_wiki.py
@@ -95,7 +95,8 @@
if options.namespace and 'help' in options.namespace:
for namespace in self.original.namespaces.values():
- pywikibot.output('%s %s' % (namespace.id, namespace.custom_name))
+ pywikibot.output(
+ '{0} {1}'.format(namespace.id, namespace.custom_name))
sys.exit()
self.sites = [pywikibot.Site(s, family) for s in sites]
@@ -174,12 +175,14 @@
else:
output += "All important pages are the same"
- output += "\n\n== Admins from original that are missing here ==\n\n"
+ output += (
+ '\n\n== Admins from original that are missing here ==\n\n')
if self.user_diff[site]:
output += "".join('* %s\n' % l.replace('_', ' ') for l in
self.user_diff[site])
else:
- output += "All users from original are also present on this wiki"
+ output += (
+ 'All users from original are also present on this wiki')
pywikibot.output(output)
sync_overview_page.text = output
diff --git a/scripts/table2wiki.py b/scripts/table2wiki.py
index b784842..10f133e 100644
--- a/scripts/table2wiki.py
+++ b/scripts/table2wiki.py
@@ -130,7 +130,8 @@
# Note that we added the ## characters in markActiveTables().
# <table> tag with attributes, with more text on the same line
newTable = re.sub(
- r'(?i)[\r\n]*?<##table## (?P<attr>[\w\W]*?)>(?P<more>[\w\W]*?)[\r\n ]*',
+ r'(?i)[\r\n]*?<##table## (?P<attr>[\w\W]*?)>'
+ r'(?P<more>[\w\W]*?)[\r\n ]*',
r'\r\n{| \g<attr>\r\n\g<more>', newTable)
# <table> tag without attributes, with more text on the same line
newTable = re.sub(r'(?i)[\r\n]*?<##table##>(?P<more>[\w\W]*?)[\r\n ]*',
diff --git a/scripts/welcome.py b/scripts/welcome.py
index 6496438..3d4d0d7 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -827,7 +827,8 @@
if locale.getlocale()[1]:
strfstr = time.strftime(
'%d %b %Y %H:%M:%S (UTC)', time.gmtime())
- if not isinstance(strfstr, UnicodeType): # py2-py3 compatibility
+ # py2-py3 compatibility
+ if not isinstance(strfstr, UnicodeType):
strfstr = strfstr.decode(locale.getlocale()[1])
else:
strfstr = time.strftime(
--
To view, visit https://gerrit.wikimedia.org/r/369669
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2fc59f971ed4b2418a135ad79be6573472825644
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/371771 )
Change subject: exceptions.py: Let Server504Error and Server414Error inherit from ServerError
......................................................................
exceptions.py: Let Server504Error and Server414Error inherit from ServerError
This is potentially a breaking change, but it makes sense and hopefully nobody
relies on catching a `ServerError` without catching `Server414Error` or
`Server504Error`.
Bug: T173289
Change-Id: I5f068886442d55aa0072815f4edbffbefa3577ae
---
M pywikibot/exceptions.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index d9dff19..2914eb7 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -464,14 +464,14 @@
pass
-class Server504Error(Error): # noqa
+class Server504Error(ServerError): # noqa
"""Server timed out with HTTP 504 code"""
pass
-class Server414Error(Error):
+class Server414Error(ServerError):
"""Server returned with HTTP 414 code."""
--
To view, visit https://gerrit.wikimedia.org/r/371771
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5f068886442d55aa0072815f4edbffbefa3577ae
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
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: jenkins-bot <>