jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Reduce usage of unicode()
......................................................................
[IMPROV] Reduce usage of unicode()
The unicode() builtin is not necessary if it's added unmodified via
format or %-notation into a unicode string (e.g. u'{0}'.format(value)).
In addition, the localized time formatting was removed. The default 'C'
locale (which is ASCII by definition) is now used instead.
If the parameter is a list or tuple it's using format to avoid problems
with Python that it interprets the tuple as multiple values. Lists too,
as they might be replaced by tuples (who knows).
Change-Id: I7ab06dc9cd7ddff6ff6654d6d611870520abc02b
---
M pywikibot/bot.py
M pywikibot/pagegenerators.py
M scripts/checkimages.py
3 files changed, 7 insertions(+), 17 deletions(-)
Approvals:
XZise: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 6e92dbf..5ac275f 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -266,7 +266,7 @@
log(u'=== Pywikibot framework v2.0 -- Logging header ===')
# script call
- log(u'COMMAND: %s' % unicode(sys.argv))
+ log(u'COMMAND: {0}'.format(sys.argv))
# script call time stamp
log(u'DATE: %s UTC' % str(datetime.datetime.utcnow()))
@@ -280,7 +280,7 @@
# system
if hasattr(os, 'uname'):
- log(u'SYSTEM: %s' % unicode(os.uname()))
+ log(u'SYSTEM: {0}'.format(os.uname()))
# config file dir
log(u'CONFIG FILE DIR: %s' % pywikibot.config2.base_dir)
@@ -319,7 +319,7 @@
log(u' %s' % ver)
if config.log_pywiki_repo_version:
- log(u'PYWIKI REPO VERSION: %s' %
unicode(version.getversion_onlinerepo()))
+ log(u'PYWIKI REPO VERSION: %s' % version.getversion_onlinerepo())
log(u'=== ' * 14)
@@ -1074,7 +1074,7 @@
if site not in self._sites:
log(u'LOADING SITE %s VERSION: %s'
- % (site, unicode(site.version())))
+ % (site, site.version()))
self._sites.add(site)
if len(self._sites) == 2:
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index a4b5b43..00e0f11 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -40,7 +40,6 @@
if sys.version_info[0] > 2:
basestring = (str, )
- unicode = str
_logger = "pagegenerators"
@@ -1966,7 +1965,7 @@
pywikibot.output(u'retrieved %d items' % data[u'status'][u'items'])
for item in data[u'items']:
- page = pywikibot.ItemPage(repo, u'Q' + unicode(item))
+ page = pywikibot.ItemPage(repo, u'Q{0}'.format(item))
try:
link = page.getSitelink(site)
except pywikibot.NoPage:
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 1310359..66b1aee 100644
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -92,7 +92,6 @@
import re
import time
import datetime
-import locale
import sys
import pywikibot
@@ -102,8 +101,6 @@
if sys.version_info[0] > 2:
basestring = (str, )
-
-locale.setlocale(locale.LC_ALL, '')
###############################################################################
# <--------------------------- Change only below! --------------------------->#
@@ -572,14 +569,8 @@
def printWithTimeZone(message):
"""Print the messages followed by the TimeZone encoded correctly."""
if message[-1] != ' ':
- message = '%s ' % unicode(message)
- if locale.getlocale()[1]:
- time_zone = unicode(time.strftime(u"%d %b %Y %H:%M:%S (UTC)",
- time.gmtime()),
- locale.getlocale()[1])
- else:
- time_zone = unicode(time.strftime(u"%d %b %Y %H:%M:%S (UTC)",
- time.gmtime()))
+ message = u'%s ' % message
+ time_zone = time.strftime(u"%d %b %Y %H:%M:%S (UTC)", time.gmtime())
pywikibot.output(u"%s%s" % (message, time_zone))
--
To view, visit https://gerrit.wikimedia.org/r/178006
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7ab06dc9cd7ddff6ff6654d6d611870520abc02b
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Nullzero <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits