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.

Change-Id: I77017db516e6573ce463628167e9c4f2cf845aab
---
M pywikibot/bot.py
M pywikibot/pagegenerators.py
M scripts/checkimages.py
3 files changed, 7 insertions(+), 17 deletions(-)

Approvals:
  Merlijn van Deen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 6e92dbf..99622dc 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: %s' % 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: %s' % 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/177993
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I77017db516e6573ce463628167e9c4f2cf845aab
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <commodorefabia...@gmx.de>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl>
Gerrit-Reviewer: XZise <commodorefabia...@gmx.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
Pywikibot-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to