jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/590281 )
Change subject: [cleanup] remove remaining unicode literals specifiers ......................................................................
[cleanup] remove remaining unicode literals specifiers
- remove commented out code parts in fixes.py, interwiki.py and imagecopy_self.py
Bug: T165911 Change-Id: Ia7954d820524101f5af45d5adab85b8f74f46375 --- M generate_user_files.py M pywikibot/data/api.py M pywikibot/fixes.py M pywikibot/site/__init__.py M pywikibot/tools/ip.py M scripts/imagecopy_self.py M scripts/interwiki.py M scripts/maintenance/make_i18n_dict.py 8 files changed, 23 insertions(+), 41 deletions(-)
Approvals: Huji: Looks good to me, approved jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py index 8abb94e..e9657df 100755 --- a/generate_user_files.py +++ b/generate_user_files.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- """Script to create user-config.py.""" # -# (C) Pywikibot team, 2010-2019 +# (C) Pywikibot team, 2010-2020 # # Distributed under the terms of the MIT license. # @@ -229,7 +229,8 @@ {botpasswords} """
-PASSFILE_CONFIG = """# This is an automatically generated file used to store +PASSFILE_CONFIG = """# -*- coding: utf-8 -*- +# This is an automatically generated file used to store # BotPasswords. # # As a simpler (but less secure) alternative to OAuth, MediaWiki allows bot @@ -239,6 +240,7 @@ # # See https://www.mediawiki.org/wiki/Manual:Pywikibot/BotPasswords for more # information. +from __future__ import absolute_import, division, unicode_literals {botpasswords}"""
@@ -338,11 +340,11 @@ botpasswordpass))
if not userlist: # Show a sample - usernames = "# usernames['{}']['{}'] = u'MyUsername'".format( + usernames = "# usernames['{}']['{}'] = 'MyUsername'".format( main_family, main_code) else: usernames = '\n'.join( - "usernames['{user.family}']['{user.code}'] = u'{user.name}'" + "usernames['{user.family}']['{user.code}'] = '{user.name}'" .format(user=user) for user in userlist) # Arbitrarily use the first key as default settings main_family, main_code = userlist[0].family, userlist[0].code diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 6e0214c..609c9f5 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1112,7 +1112,7 @@ True >>> 'query' in data True - >>> sorted(str(key) for key in data[u'query'].keys()) + >>> sorted(str(key) for key in data['query'].keys()) ['namespaces', 'userinfo']
""" diff --git a/pywikibot/fixes.py b/pywikibot/fixes.py index ce6ee8a..4db13d0 100644 --- a/pywikibot/fixes.py +++ b/pywikibot/fixes.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """File containing all standard fixes.""" # -# (C) Pywikibot team, 2008-2019 +# (C) Pywikibot team, 2008-2020 # # Distributed under the terms of the MIT license. # @@ -96,9 +96,6 @@ 'de': 'Bot: korrigiere Grammatik', }, 'replacements': [ - # (u'([Ss]owohl) ([^,.]+?), als auch', r'\1 \2 als auch'), - # (u'([Ww]eder) ([^,.]+?), noch', r'\1 \2 noch'), - # # Vorsicht bei Substantiven, z. B. 3-Jähriger! (r'(\d+)(minütig|stündig|tägig|wöchig|jährig|minütlich|stündlich' r'|täglich|wöchentlich|jährlich|fach|mal|malig|köpfig|teilig' @@ -128,7 +125,6 @@ # z.B. nach Quellenangaben (r'([a-zäöüß](]])?) ([,.!?]) (([[)?[a-zäöüA-ZÄÖÜ])', r'\1\3 \4'), - # (u'([a-z].)([A-Z])', r'\1 \2'), ], 'exceptions': { 'inside-tags': [ @@ -357,16 +353,6 @@ 'de': 'Bot: Korrigiere Datumsformat', }, 'replacements': [ - # space after birth sign w/ year - # (u'(*(\d{3,4})', u'(* \1'), - # space after death sign w/ year - # (u'†(\d{3,4})', u'† \1'), - # (u'†(\d{3,4})', u'† \1'), - # space after birth sign w/ linked date - # (u'(*[[(\d)', u'(* [[\1'), - # space after death sign w/ linked date - # (u'†[[(\d)', u'† [[\1'), - # (u'†[[(\d)', u'† [[\1'), (r'[[(\d+. (?:Januar|Februar|März|April|Mai|Juni|Juli|August|' r'September|Oktober|November|Dezember)) (\d{1,4})]]', r'[[\1]] [[\2]]'), @@ -449,9 +435,6 @@ 'ar': 'تدقيق إملائي', }, 'replacements': [ - # FIXME: Do not replace comma in non-Arabic text, - # interwiki, image links or <math> syntax. - # (u' ,', u' ،'), (r'(\A|\s)إمرأة(\Z|\s)', '\1امرأة\2'), (r'(\A|\s)الى(\Z|\s)', '\1إلى\2'), (r'(\A|\s)إسم(\Z|\s)', '\1اسم\2'), @@ -646,8 +629,6 @@ ('eunet.yu', 'eunet.rs'), ('www.zastava-arms.co.yu', 'www.zastava-arms.co.rs'), ('www.airportnis.co.yu', 'www.airportnis.rs'), - # Archive links don't seem to work - # (u'www.danas.co.yu', u'www.danas.rs'), ('www.belex.co.yu', 'www.belex.rs'), ('beograd.org.yu', 'beograd.rs'), ('www.vlada.cg.yu', 'www.vlada.me'), diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py index fc016c2..3e07439 100644 --- a/pywikibot/site/__init__.py +++ b/pywikibot/site/__init__.py @@ -2886,8 +2886,8 @@ keys: int in the range [0, 1, ..., 4] values: category name corresponding to the 'key' quality level e.g. on en.wikisource: - {0: u'Without text', 1: u'Not proofread', 2: u'Problematic', - 3: u'Proofread', 4: u'Validated'} + {0: 'Without text', 1: 'Not proofread', 2: 'Problematic', + 3: 'Proofread', 4: 'Validated'}
@param expiry: either a number of days or a datetime.timedelta object @type expiry: int (days), L{datetime.timedelta}, False (config) diff --git a/pywikibot/tools/ip.py b/pywikibot/tools/ip.py index 9130251..b98289d 100644 --- a/pywikibot/tools/ip.py +++ b/pywikibot/tools/ip.py @@ -39,7 +39,7 @@ if PY2: # This backport fails many tests # https://pypi.org/project/py2-ipaddress - # It accepts u'1111' as a valid IP address. + # It accepts '1111' as a valid IP address. try: ip_address('1111') ip_address = None @@ -49,7 +49,7 @@
# This backport only fails a few tests if given a unicode object # https://pypi.org/project/ipaddress - # However while it rejects u'1111', it will consider '1111' valid + # However while it rejects '1111', it will consider b'1111' valid try: ip_address(b'1111') warn('ipaddress backport is defective; patching; install ipaddr', @@ -63,7 +63,7 @@
ip_address = ip_address_patched except ValueError: - # This means ipaddress has correctly determined '1111' is invalid + # This means ipaddress has correctly determined b'1111' is invalid pass elif not ip_address: warn('Importing ipaddr.IPAddress failed: %s\n' diff --git a/scripts/imagecopy_self.py b/scripts/imagecopy_self.py index a38582d..ba9a69c 100644 --- a/scripts/imagecopy_self.py +++ b/scripts/imagecopy_self.py @@ -45,7 +45,7 @@ # English Wikipedia specific bot by: # (C) Multichill 2010-2012 # -# (C) Pywikibot team, 2010-2019 +# (C) Pywikibot team, 2010-2020 # # Distributed under the terms of the MIT license. # @@ -510,9 +510,6 @@ def getNewFieldsFromFreetext(self, imagepage): """Extract fields from free text for the new information template.""" text = imagepage.get() - # text = re.sub(u'== Summary ==', u'', text, re.IGNORECASE) - # text = re.sub(u'== Licensing ==', u'', text, re.IGNORECASE) - # text = re.sub('{{(self|self2)|[^}]+}}', '', text, re.I)
for toRemove in sourceGarbage[imagepage.site.lang]: text = re.sub(toRemove, '', text, flags=re.IGNORECASE) diff --git a/scripts/interwiki.py b/scripts/interwiki.py index 8f9fd66..ca28b92 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -340,8 +340,8 @@ # (C) Rob W.W. Hooft, 2003 # (C) Daniel Herding, 2004 # (C) Yuri Astrakhan, 2005-2006 -# (C) xqt, 2009-2019 -# (C) Pywikibot team, 2007-2019 +# (C) xqt, 2009-2020 +# (C) Pywikibot team, 2007-2020 # # Distributed under the terms of the MIT license. # @@ -1853,7 +1853,6 @@ return False pywikibot.showDiff(oldtext, newtext)
- # pywikibot.output(u"NOTE: Replace %s" % page) # Determine whether we need permission to submit ask = False
diff --git a/scripts/maintenance/make_i18n_dict.py b/scripts/maintenance/make_i18n_dict.py index 5347fd3..e4f583d 100755 --- a/scripts/maintenance/make_i18n_dict.py +++ b/scripts/maintenance/make_i18n_dict.py @@ -25,8 +25,8 @@
bot.to_json()
""" # -# (C) xqt, 2013-2019 -# (C) Pywikibot team, 2013-2019 +# (C) xqt, 2013-2020 +# (C) Pywikibot team, 2013-2020 # # Distributed under the terms of the MIT license. # @@ -39,6 +39,7 @@ import os
from pywikibot import config +from pywikibot.tools import PY2
class i18nBot(object): # noqa: N801 @@ -78,14 +79,16 @@ keys.insert(0, 'en')
print('# -*- coding: utf-8 -*-') + if PY2: + print('from __future__ import unicode_literals') print('msg = {') for code in keys: print(" '%s': {" % code) for msg in sorted(self.messages.values()): label = '{}-{}'.format(self.scriptname, msg) if label in self.dict[code]: - print(" '%s': u'%s'," % (label, - self.dict[code][label])) + print(" '{}': '{}'," + .format(label, self.dict[code][label])) print(' },') print('};')
pywikibot-commits@lists.wikimedia.org