jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462491 )
Change subject: [cleanup] cleanup scripts/lonelypages.py
......................................................................
[cleanup] cleanup scripts/lonelypages.py
- use single quotes for string literals and double quotes
**only** if they consist of single quotes within them
- use str.format(...) instead of modulo for type specifier
arguments
- remove preleading "u" from strings
Change-Id: I2cbc7438b4bf3fb2d7642ef7df41a9c9ff1e7156
---
M scripts/lonelypages.py
1 file changed, 29 insertions(+), 22 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/lonelypages.py b/scripts/lonelypages.py
index ad83725..39b7cdd 100755
--- a/scripts/lonelypages.py
+++ b/scripts/lonelypages.py
@@ -128,7 +128,7 @@
except ValueError as e:
orphan_template = e
if orphan_template is None or isinstance(orphan_template, ValueError):
- err_message = 'Missing configuration for site %s' % self.site
+ err_message = 'Missing configuration for site {}'.format(self.site)
suggest_help(exception=orphan_template, additional_text=err_message)
sys.exit(err_message)
else:
@@ -139,11 +139,12 @@
try:
self.disambigtext = self.disambigpage.get()
except pywikibot.NoPage:
- pywikibot.output(u"%s doesn't esist, skip!" % self.disambigpage.title())
+ pywikibot.output("{0} doesn't esist, skip!"
+ .format(self.disambigpage.title()))
self.disambigtext = ''
except pywikibot.IsRedirectPage:
- pywikibot.output(u"%s is a redirect, don't use it!"
- % self.disambigpage.title())
+ pywikibot.output("{0} is a redirect, don't use it!"
+ .format(self.disambigpage.title()))
self.options['disambigPage'] = None
@property
@@ -159,11 +160,12 @@
getenable = enable.get()
except pywikibot.NoPage:
pywikibot.output(
- u"%s doesn't esist, I use the page as if it was blank!"
- % enable.title())
+ "{0} doesn't esist, I use the page as if it was blank!"
+ .format(enable.title()))
getenable = ''
except pywikibot.IsRedirectPage:
- pywikibot.output(u"%s is a redirect, skip!" % enable.title())
+ pywikibot.output('{0} is a redirect, skip!'
+ .format(enable.title()))
getenable = ''
return getenable == 'enable'
return True
@@ -180,46 +182,51 @@
def treat(self, page):
"""Check if page is applicable and not marked and add template then."""
- pywikibot.output(u"Checking %s..." % page.title())
+ pywikibot.output('Checking {0}...'.format(page.title()))
if page.isRedirectPage(): # If redirect, skip!
- pywikibot.output(u'%s is a redirect! Skip...' % page.title())
+ pywikibot.output('{0} is a redirect! Skip...'
+ .format(page.title()))
return
refs = list(page.getReferences(total=1))
if len(refs) > 0:
- pywikibot.output(u"%s isn't orphan! Skip..." % page.title())
+ pywikibot.output("{0} isn't orphan! Skip..."
+ .format(page.title()))
return
else:
# no refs, no redirect; check if there's already the template
try:
oldtxt = page.get()
except pywikibot.NoPage:
- pywikibot.output(u"%s doesn't exist! Skip..." % page.title())
+ pywikibot.output("{0} doesn't exist! Skip..."
+ .format(page.title()))
return
except pywikibot.IsRedirectPage:
- pywikibot.output(u"%s is a redirect! Skip..." % page.title())
+ pywikibot.output('{0} is a redirect! Skip...'
+ .format(page.title()))
return
if self.settings.regex.search(oldtxt):
pywikibot.output(
- u'Your regex has found something in %s, skipping...'
- % page.title())
+ 'Your regex has found something in {0}, skipping...'
+ .format(page.title()))
return
if page.isDisambig() and self.getOption('disambigPage') is not None:
- pywikibot.output(u'%s is a disambig page, report..'
- % page.title())
+ pywikibot.output('{0} is a disambig page, report..'
+ .format(page.title()))
if not page.title().lower() in self.disambigtext.lower():
- self.disambigtext = u"%s\n*[[%s]]" % (self.disambigtext, page.title())
+ self.disambigtext = '{0}\n*[[{1}]]'.format(
+ self.disambigtext, page.title())
self.disambigpage.text = self.disambigtext
self.disambigpage.save(self.commentdisambig)
return
# Is the page a disambig but there's not disambigPage? Skip!
elif page.isDisambig():
- pywikibot.output(u'%s is a disambig page, skip...'
- % page.title())
+ pywikibot.output('{0} is a disambig page, skip...'
+ .format(page.title()))
return
else:
# Ok, the page need the template. Let's put it there!
# Adding the template in the text
- newtxt = '%s\n%s' % (self.settings.template, oldtxt)
+ newtxt = '{0}\n{1}'.format(self.settings.template, oldtxt)
self.userPut(page, oldtxt, newtxt, summary=self.comment)
@@ -242,13 +249,13 @@
if arg.startswith('-enable'):
if len(arg) == 7:
options['enablePage'] = pywikibot.input(
- u'Would you like to check if the bot should run or not?')
+ 'Would you like to check if the bot should run or not?')
else:
options['enablePage'] = arg[8:]
elif arg.startswith('-disambig'):
if len(arg) == 9:
options['disambigPage'] = pywikibot.input(
- u'In which page should the bot save the disambig pages?')
+ 'In which page should the bot save the disambig pages?')
else:
options['disambigPage'] = arg[10:]
elif arg == '-always':
--
To view, visit https://gerrit.wikimedia.org/r/462491
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: I2cbc7438b4bf3fb2d7642ef7df41a9c9ff1e7156
Gerrit-Change-Number: 462491
Gerrit-PatchSet: 4
Gerrit-Owner: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462433 )
Change subject: [cleanup] clean scripts/redirect.py
......................................................................
[cleanup] clean scripts/redirect.py
- remove preleading "u" from strings
- use single quotes for string literals and double quotes
**only** if they consist of single quotes within them
- use str.format(...) instead of modulo for type specifier
arguments
- use "+" to concatenate strings in some cases
Change-Id: Ie8ccaa2a43bd0c0b45c8241793a86015c60aa07e
---
M scripts/redirect.py
1 file changed, 56 insertions(+), 53 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 78d7be1..5fff9d7 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -161,7 +161,7 @@
readPagesCount += 1
# always print status message after 10000 pages
if readPagesCount % 10000 == 0:
- pywikibot.output(u'%i pages read...' % readPagesCount)
+ pywikibot.output('{0} pages read...'.format(readPagesCount))
if len(self.namespaces) > 0:
if pywikibot.Page(self.site, entry.title).namespace() \
not in self.namespaces:
@@ -180,8 +180,8 @@
except pywikibot.SiteDefinitionError as e:
pywikibot.log(e)
pywikibot.output(
- u'NOTE: Ignoring {0} which is a redirect ({1}) to an '
- u'unknown site.'.format(entry.title, target))
+ 'NOTE: Ignoring {0} which is a redirect ({1}) to an '
+ 'unknown site.'.format(entry.title, target))
target_link = None
else:
if target_link.site != self.site:
@@ -195,8 +195,8 @@
source = pywikibot.Link(entry.title, self.site)
if target_link.anchor:
pywikibot.output(
- u'HINT: %s is a redirect with a pipelink.'
- % entry.title)
+ 'HINT: {0} is a redirect with a pipelink.'
+ .format(entry.title))
redict[space_to_underscore(source)] = (
space_to_underscore(target_link))
if alsoGetPageTitles:
@@ -265,9 +265,9 @@
'pageids': apiQ})
data = gen.submit()
if 'error' in data:
- raise RuntimeError("API query error: %s" % data)
+ raise RuntimeError('API query error: {0}'.format(data))
if data == [] or 'query' not in data:
- raise RuntimeError("No results given.")
+ raise RuntimeError('No results given.')
pages = {}
redirects = {x['from']: x['to']
for x in data['query']['redirects']}
@@ -310,7 +310,7 @@
elif self.xmlFilename:
# retrieve information from XML dump
pywikibot.output(
- u'Getting a list of all redirects and of all page titles...')
+ 'Getting a list of all redirects and of all page titles...')
redirs, pageTitles = self.get_redirects_from_dump(
alsoGetPageTitles=True)
for (key, value) in redirs.items():
@@ -347,8 +347,8 @@
# redirect as well
if num > self.offset and value in redict:
yield key
- pywikibot.output(u'\nChecking redirect %i of %i...'
- % (num + 1, len(redict)))
+ pywikibot.output('\nChecking redirect {0} of {1}...'
+ .format(num + 1, len(redict)))
elif self.page_title:
yield self.page_title
else:
@@ -364,11 +364,11 @@
start = (datetime.datetime.utcnow() -
datetime.timedelta(0, self.offset * 3600))
# self.offset hours ago
- offset_time = start.strftime("%Y%m%d%H%M%S")
+ offset_time = start.strftime('%Y%m%d%H%M%S')
pywikibot.output('Retrieving {0} moved pages...'
''.format(str(self.api_number)
if self.api_number is not None else 'all'))
- move_gen = self.site.logevents(logtype="move", start=offset_time)
+ move_gen = self.site.logevents(logtype='move', start=offset_time)
if self.api_number:
move_gen.set_maximum_items(self.api_number)
pywikibot.output('.', newline=False)
@@ -473,8 +473,8 @@
if page.site.logged_in(sysop=True):
page.delete(reason, prompt=False)
elif self.sdtemplate:
- pywikibot.output(u"No sysop in user-config.py, "
- u"put page to speedy deletion.")
+ pywikibot.output('No sysop in user-config.py, '
+ 'put page to speedy deletion.')
try:
content = page.get(get_redirect=True)
except pywikibot.SectionError:
@@ -493,18 +493,20 @@
try:
targetPage = redir_page.getRedirectTarget()
except pywikibot.CircularRedirect:
- pywikibot.output('%s is a circular redirect.' % redir_page.title())
+ pywikibot.output('{0} is a circular redirect.'
+ .format(redir_page.title()))
except pywikibot.InvalidTitle:
pywikibot.exception()
except pywikibot.InterwikiRedirectPage:
- pywikibot.output('%s is on another site.' % redir_page.title())
+ pywikibot.output('{0} is on another site.'
+ .format(redir_page.title()))
else:
try:
targetPage.get()
except pywikibot.BadTitle as e:
pywikibot.warning(
- u'Redirect target %s is not a valid page title.'
- % str(e)[10:])
+ 'Redirect target {0} is not a valid page title.'
+ .format(str(e)[10:]))
except pywikibot.InvalidTitle:
pywikibot.exception()
except pywikibot.NoPage:
@@ -516,14 +518,14 @@
if movedTarget:
if not movedTarget.exists():
# FIXME: Test to another move
- pywikibot.output(u'Target page %s does not exist'
- % (movedTarget))
+ pywikibot.output('Target page {0} does not exist'
+ .format(movedTarget))
elif redir_page == movedTarget:
pywikibot.output(
'Redirect to target page forms a redirect loop')
else:
- pywikibot.output(u'%s has been moved to %s'
- % (redir_page, movedTarget))
+ pywikibot.output('{0} has been moved to {1}'
+ .format(redir_page, movedTarget))
reason = i18n.twtranslate(self.site,
'redirect-fix-broken-moved',
{'to': movedTarget.title(
@@ -537,60 +539,61 @@
ignore_save_related_errors=True,
ignore_server_errors=True)
if not done and self.user_confirm(
- u'Redirect target %s does not exist.\n'
- u'Do you want to delete %s?'
- % (targetPage.title(as_link=True),
- redir_page.title(as_link=True))):
+ 'Redirect target {0} does not exist.\n'
+ 'Do you want to delete {1}?'
+ .format(targetPage.title(as_link=True),
+ redir_page.title(as_link=True))):
self.delete_redirect(redir_page, 'redirect-remove-broken')
elif not (self.getOption('delete') or movedTarget):
pywikibot.output(
'Cannot fix or delete the broken redirect')
except pywikibot.IsRedirectPage:
pywikibot.output(
- "Redirect target {0} is also a redirect! {1}".format(
+ 'Redirect target {0} is also a redirect! {1}'.format(
targetPage.title(as_link=True),
"Won't delete anything."
- if self.getOption('delete') else "Skipping."))
+ if self.getOption('delete') else 'Skipping.'))
else:
# we successfully get the target page, meaning that
# it exists and is not a redirect: no reason to touch it.
pywikibot.output(
- "Redirect target {0} does exist! {1}".format(
+ 'Redirect target {0} does exist! {1}'.format(
targetPage.title(as_link=True),
"Won't delete anything."
- if self.getOption('delete') else "Skipping."))
+ if self.getOption('delete') else 'Skipping.'))
def fix_1_double_redirect(self):
"""Treat one double redirect."""
newRedir = redir = self.current_page
redirList = [] # bookkeeping to detect loops
while True:
- redirList.append(u'%s:%s' % (newRedir.site.lang,
- newRedir.title(with_section=False)))
+ redirList.append('{0}:{1}'
+ .format(newRedir.site.lang,
+ 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(as_link=True))
+ 'Skipping: Redirect target {0} is not a redirect.'
+ .format(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(as_link=True))
+ "Redirect target section {0} doesn't exist."
+ .format(newRedir.title(as_link=True)))
except (pywikibot.CircularRedirect,
pywikibot.InterwikiRedirectPage,
pywikibot.UnsupportedPage) as e:
pywikibot.exception(e)
- pywikibot.output(u"Skipping %s." % newRedir)
+ pywikibot.output('Skipping {0}.'.format(newRedir))
break
except pywikibot.BadTitle as e:
# str(e) is in the format 'BadTitle: [[Foo]]'
pywikibot.warning(
- u'Redirect target %s is not a valid page title.'
- % str(e)[10:])
+ 'Redirect target {0} is not a valid page title.'
+ .format(str(e)[10:]))
break
except pywikibot.NoPage:
if self.getOption('always'):
@@ -603,13 +606,13 @@
"Redirect target {} doesn't exist."
.format(newRedir.title(as_link=True)))
except pywikibot.ServerError:
- pywikibot.output(u'Skipping due to server error: '
- u'No textarea found')
+ pywikibot.output('Skipping due to server error: '
+ 'No textarea found')
break
else:
pywikibot.output(
- u' Links to: %s.'
- % targetPage.title(as_link=True))
+ ' Links to: {0}.'
+ .format(targetPage.title(as_link=True)))
try:
mw_msg = targetPage.site.mediawiki_message(
'wikieditor-toolbar-tool-redirect-example')
@@ -618,16 +621,16 @@
else:
if targetPage.title() == mw_msg:
pywikibot.output(
- u"Skipping toolbar example: Redirect source is "
- u"potentially vandalized.")
+ 'Skipping toolbar example: Redirect source is '
+ 'potentially vandalized.')
break
# watch out for redirect loops
- if redirList.count(u'%s:%s'
- % (targetPage.site.lang,
- targetPage.title(with_section=False))):
+ if redirList.count('{0}:{1}'.format(
+ targetPage.site.lang,
+ targetPage.title(with_section=False))):
pywikibot.warning(
- u'Redirect target %s forms a redirect loop.'
- % targetPage.title(as_link=True))
+ 'Redirect target {0} forms a redirect loop.'
+ .format(targetPage.title(as_link=True)))
break # FIXME: doesn't work. edits twice!
if self.getOption('delete'):
# Delete the two redirects
@@ -640,14 +643,14 @@
else: # redirect target found
if targetPage.isStaticRedirect():
pywikibot.output(
- u" Redirect target is STATICREDIRECT.")
+ ' Redirect target is STATICREDIRECT.')
else:
newRedir = targetPage
continue
try:
oldText = redir.get(get_redirect=True)
except pywikibot.BadTitle:
- pywikibot.output(u"Bad Title Error")
+ pywikibot.output('Bad Title Error')
break
if self.is_repo and redir.namespace() == self.repo.item_namespace:
redir = pywikibot.ItemPage(self.repo, redir.title())
@@ -748,7 +751,7 @@
2, ArgumentDeprecationWarning,
since='20160210')
else:
- pywikibot.output(u'Unknown argument: %s' % arg)
+ pywikibot.output('Unknown argument: ' + arg)
if namespaces:
gen_options['namespaces'] = namespaces
--
To view, visit https://gerrit.wikimedia.org/r/462433
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: Ie8ccaa2a43bd0c0b45c8241793a86015c60aa07e
Gerrit-Change-Number: 462433
Gerrit-PatchSet: 3
Gerrit-Owner: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462404 )
Change subject: [cleanup] cleanup scripts/replace.py
......................................................................
[cleanup] cleanup scripts/replace.py
- remove preleading "u" from strings
- use single quotes for string literals and double quotes
**only** if they consist of single quotes within them
- use str.format(...) instead of modulo for type specifier
arguments
- use "+" to concatenate strings in some cases
Change-Id: I23723262299d44ca02f12f10e393f19a40bd9d2c
---
M scripts/replace.py
1 file changed, 53 insertions(+), 51 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py
index f36d6d2..dd6924d 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -430,9 +430,9 @@
self.skipping = bool(xmlStart)
self.excsInside = []
- if "inside-tags" in self.exceptions:
+ if 'inside-tags' in self.exceptions:
self.excsInside += self.exceptions['inside-tags']
- if "inside" in self.exceptions:
+ if 'inside' in self.exceptions:
self.excsInside += self.exceptions['inside']
from pywikibot import xmlreader
if site:
@@ -468,8 +468,8 @@
try:
if not self.skipping:
pywikibot.output(
- u'To resume, use "-xmlstart:%s" on the command line.'
- % entry.title)
+ 'To resume, use "-xmlstart:{0}" on the command line.'
+ .format(entry.title))
except NameError:
pass
@@ -479,11 +479,11 @@
@rtype: bool
"""
- if "title" in self.exceptions:
+ if 'title' in self.exceptions:
for exc in self.exceptions['title']:
if exc.search(title):
return True
- if "require-title" in self.exceptions:
+ if 'require-title' in self.exceptions:
for req in self.exceptions['require-title']:
if not req.search(title): # if not all requirements are met:
return True
@@ -496,7 +496,7 @@
@rtype: bool
"""
- if "text-contains" in self.exceptions:
+ if 'text-contains' in self.exceptions:
for exc in self.exceptions['text-contains']:
if exc.search(text):
return True
@@ -609,7 +609,7 @@
@rtype: bool
"""
- if "text-contains" in self.exceptions:
+ if 'text-contains' in self.exceptions:
for exc in self.exceptions['text-contains']:
if exc.search(original_text):
return True
@@ -710,11 +710,11 @@
else:
comma = self.site.mediawiki_message('comma-separator')
default_summary = comma.join(
- u'-{0} +{1}'.format(*default_summary)
+ '-{0} +{1}'.format(*default_summary)
for default_summary in default_summaries)
summary_messages.insert(0, i18n.twtranslate(
self.site, 'replace-replacing',
- {'description': u' ({0})'.format(default_summary)}
+ {'description': ' ({0})'.format(default_summary)}
))
semicolon = self.site.mediawiki_message('semicolon-separator')
return semicolon.join(summary_messages)
@@ -726,19 +726,19 @@
for page in self.generator:
if self.isTitleExcepted(page.title()):
pywikibot.output(
- u'Skipping %s because the title is on the exceptions list.'
- % page.title(as_link=True))
+ 'Skipping {0} because the title is on the exceptions list.'
+ .format(page.title(as_link=True)))
continue
try:
# Load the page's text from the wiki
original_text = page.get(get_redirect=True)
if not page.canBeEdited():
- pywikibot.output(u"You can't edit page %s"
- % page.title(as_link=True))
+ pywikibot.output("You can't edit page "
+ + page.title(as_link=True))
continue
except pywikibot.NoPage:
- pywikibot.output('Page %s not found' % page.title(
- as_link=True))
+ pywikibot.output('Page {0} not found'
+ .format(page.title(as_link=True)))
continue
applied = set()
new_text = original_text
@@ -746,9 +746,9 @@
context = 0
while True:
if self.isTextExcepted(new_text):
- pywikibot.output(u'Skipping %s because it contains text '
- u'that is on the exceptions list.'
- % page.title(as_link=True))
+ pywikibot.output('Skipping {0} because it contains text '
+ 'that is on the exceptions list.'
+ .format(page.title(as_link=True)))
break
while new_text != last_text:
last_text = new_text
@@ -757,8 +757,8 @@
if not self.recursive:
break
if new_text == original_text:
- pywikibot.output(u'No changes were necessary in %s'
- % page.title(as_link=True))
+ pywikibot.output('No changes were necessary in '
+ + page.title(as_link=True))
break
if hasattr(self, 'addedCat'):
# Fetch only categories in wikitext, otherwise the others
@@ -777,7 +777,7 @@
if self.getOption('always'):
break
choice = pywikibot.input_choice(
- u'Do you want to accept these changes?',
+ 'Do you want to accept these changes?',
[('Yes', 'y'), ('No', 'n'), ('Edit original', 'e'),
('edit Latest', 'l'), ('open in Browser', 'b'),
('More context', 'm'), ('All', 'a')],
@@ -806,8 +806,8 @@
try:
original_text = page.get(get_redirect=True, force=True)
except pywikibot.NoPage:
- pywikibot.output(u'Page %s has been deleted.'
- % page.title())
+ pywikibot.output('Page {0} has been deleted.'
+ .format(page.title()))
break
new_text = original_text
last_text = None
@@ -822,8 +822,9 @@
quiet=True)
while not self._pending_processed_titles.empty():
proc_title, res = self._pending_processed_titles.get()
- pywikibot.output('Page %s%s saved'
- % (proc_title, '' if res else ' not'))
+ pywikibot.output('Page {0}{1} saved'
+ .format(proc_title,
+ '' if res else ' not'))
# choice must be 'N'
break
if self.getOption('always') and new_text != original_text:
@@ -832,23 +833,24 @@
page.save(summary=self.generate_summary(applied),
callback=self._replace_sync_callback, quiet=True)
except pywikibot.EditConflict:
- pywikibot.output(u'Skipping %s because of edit conflict'
- % (page.title(),))
+ pywikibot.output('Skipping {0} because of edit conflict'
+ .format(page.title(),))
except pywikibot.SpamfilterError as e:
pywikibot.output(
- u'Cannot change %s because of blacklist entry %s'
- % (page.title(), e.url))
+ 'Cannot change {0} because of blacklist entry {1}'
+ .format(page.title(), e.url))
except pywikibot.LockedPage:
- pywikibot.output(u'Skipping %s (locked page)'
- % (page.title(),))
+ pywikibot.output('Skipping {0} (locked page)'
+ .format(page.title(),))
except pywikibot.PageNotSaved as error:
- pywikibot.output(u'Error putting page: %s'
- % (error.args,))
+ pywikibot.output('Error putting page: {0}'
+ .format(error.args,))
if self._pending_processed_titles.qsize() > 50:
while not self._pending_processed_titles.empty():
proc_title, res = self._pending_processed_titles.get()
- pywikibot.output('Page %s%s saved'
- % (proc_title, '' if res else ' not'))
+ pywikibot.output('Page {0}{1} saved'
+ .format(proc_title,
+ '' if res else ' not'))
def prepareRegexForMySQL(pattern):
@@ -876,7 +878,7 @@
add_cat = None
gen = None
# summary message
- edit_summary = u""
+ edit_summary = ''
# Array which will collect commandline parameters.
# First element is original text, second element is replacement text.
commandline_replacements = []
@@ -936,7 +938,7 @@
elif arg.startswith('-xmlstart'):
if len(arg) == 9:
xmlStart = pywikibot.input(
- u'Please enter the dumped article to start with:')
+ 'Please enter the dumped article to start with:')
else:
xmlStart = arg[10:]
elif arg.startswith('-xml'):
@@ -996,7 +998,7 @@
if arg == '-pairsfile':
replacement_file = pywikibot.input(
- u'Please enter the filename to read replacements from:')
+ 'Please enter the filename to read replacements from:')
else:
replacement_file = arg[len('-pairsfile:'):]
else:
@@ -1019,7 +1021,7 @@
# strip newlines, but not other characters
file_replacements = f.read().splitlines()
except (IOError, OSError) as e:
- pywikibot.error(u'Error loading {0}: {1}'.format(
+ pywikibot.error('Error loading {0}: {1}'.format(
replacement_file, e))
return False
@@ -1030,13 +1032,13 @@
return False
# Strip BOM from first line
- file_replacements[0].lstrip(u'\uFEFF')
+ file_replacements[0].lstrip('\uFEFF')
commandline_replacements.extend(file_replacements)
if not(commandline_replacements or fixes_set) or manual_input:
old = pywikibot.input('Please enter the text that should be replaced:')
while old:
- new = pywikibot.input(u'Please enter the new text:')
+ new = pywikibot.input('Please enter the new text:')
commandline_replacements += [old, new]
old = pywikibot.input(
'Please enter another text that should be replaced,'
@@ -1051,7 +1053,7 @@
single_summary = i18n.twtranslate(
site, 'replace-replacing',
{'description':
- ' (-%s +%s)' % (replacement.old, replacement.new)}
+ ' (-{0} +{1})'.format(replacement.old, replacement.new)}
)
replacements.append(replacement)
@@ -1062,8 +1064,8 @@
try:
fix = fixes.fixes[fix_name]
except KeyError:
- pywikibot.output(u'Available predefined fixes are: %s'
- % ', '.join(fixes.fixes.keys()))
+ pywikibot.output('Available predefined fixes are: {0}'
+ .format(', '.join(fixes.fixes.keys())))
if not fixes.user_fixes_loaded:
pywikibot.output('The user fixes file could not be found: '
'{0}'.format(fixes.filename))
@@ -1072,7 +1074,7 @@
pywikibot.warning('No replacements defined for fix '
'"{0}"'.format(fix_name))
continue
- if "msg" in fix:
+ if 'msg' in fix:
if isinstance(fix['msg'], basestring):
set_summary = i18n.twtranslate(site, str(fix['msg']))
else:
@@ -1133,9 +1135,9 @@
if ((not edit_summary or edit_summary is True) and
(missing_fixes_summaries or single_summary)):
if single_summary:
- pywikibot.output(u'The summary message for the command line '
- 'replacements will be something like: %s'
- % single_summary)
+ pywikibot.output('The summary message for the command line '
+ 'replacements will be something like: '
+ + 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) '
@@ -1206,8 +1208,8 @@
# 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)
+ pywikibot.output('\n{0} pages changed.'.format(bot.changed_pages))
-if __name__ == "__main__":
+if __name__ == '__main__':
main()
--
To view, visit https://gerrit.wikimedia.org/r/462404
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: I23723262299d44ca02f12f10e393f19a40bd9d2c
Gerrit-Change-Number: 462404
Gerrit-PatchSet: 2
Gerrit-Owner: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)