XZise has uploaded a new change for review. https://gerrit.wikimedia.org/r/202934
Change subject: Revert "[IMPROV] Use unicode_literals" ...................................................................... Revert "[IMPROV] Use unicode_literals" Although my personal Travis build succeeded the most recent one with this merged in does not: https://travis-ci.org/wikimedia/pywikibot-core/builds/57652605 This reverts commit 1e54a7d6886d56a21101900025038e25bab5ad03. Change-Id: I3dcf96b96727a63b874d983484247539885a1bff --- M pwb.py M pywikibot/__init__.py M pywikibot/backports.py M pywikibot/bot.py M pywikibot/botirc.py M pywikibot/comms/__init__.py M pywikibot/comms/http.py M pywikibot/comms/rcstream.py M pywikibot/comms/threadedhttp.py M pywikibot/compat/catlib.py M pywikibot/compat/query.py M pywikibot/compat/userlib.py M pywikibot/config2.py M pywikibot/data/__init__.py M pywikibot/data/api.py M pywikibot/data/wikidataquery.py M pywikibot/data/wikistats.py M pywikibot/date.py M pywikibot/diff.py M pywikibot/echo.py M pywikibot/editor.py M pywikibot/exceptions.py M pywikibot/families/__init__.py M pywikibot/families/anarchopedia_family.py M pywikibot/families/battlestarwiki_family.py M pywikibot/families/commons_family.py M pywikibot/families/i18n_family.py M pywikibot/families/incubator_family.py M pywikibot/families/lyricwiki_family.py M pywikibot/families/mediawiki_family.py M pywikibot/families/meta_family.py M pywikibot/families/omegawiki_family.py M pywikibot/families/osm_family.py M pywikibot/families/outreach_family.py M pywikibot/families/species_family.py M pywikibot/families/strategy_family.py M pywikibot/families/test_family.py M pywikibot/families/vikidia_family.py M pywikibot/families/wikia_family.py M pywikibot/families/wikibooks_family.py M pywikibot/families/wikidata_family.py M pywikibot/families/wikimedia_family.py M pywikibot/families/wikinews_family.py M pywikibot/families/wikipedia_family.py M pywikibot/families/wikiquote_family.py M pywikibot/families/wikisource_family.py M pywikibot/families/wikitech_family.py M pywikibot/families/wikiversity_family.py M pywikibot/families/wikivoyage_family.py M pywikibot/families/wiktionary_family.py M pywikibot/families/wowwiki_family.py M pywikibot/family.py M pywikibot/fixes.py M pywikibot/i18n.py M pywikibot/interwiki_graph.py M pywikibot/logentries.py M pywikibot/login.py M pywikibot/page.py M pywikibot/pagegenerators.py M pywikibot/plural.py M pywikibot/site.py M pywikibot/textlib.py M pywikibot/throttle.py M pywikibot/titletranslate.py M pywikibot/tools/__init__.py M pywikibot/tools/ip.py M pywikibot/userinterfaces/__init__.py M pywikibot/userinterfaces/cgi_interface.py M pywikibot/userinterfaces/gui.py M pywikibot/userinterfaces/terminal_interface.py M pywikibot/userinterfaces/terminal_interface_base.py M pywikibot/userinterfaces/terminal_interface_unix.py M pywikibot/userinterfaces/terminal_interface_win32.py M pywikibot/userinterfaces/transliteration.py M pywikibot/userinterfaces/win32_unicode.py M pywikibot/version.py M pywikibot/weblib.py M pywikibot/xmlreader.py M scripts/add_text.py M scripts/archivebot.py M scripts/basic.py M scripts/blockpageschecker.py M scripts/blockreview.py M scripts/capitalize_redirects.py M scripts/casechecker.py M scripts/catall.py M scripts/category.py M scripts/category_redirect.py M scripts/cfd.py M scripts/checkimages.py M scripts/claimit.py M scripts/clean_sandbox.py M scripts/commons_link.py M scripts/commonscat.py M scripts/coordinate_import.py M scripts/cosmetic_changes.py M scripts/create_categories.py M scripts/data_ingestion.py M scripts/delete.py M scripts/disambredir.py M scripts/editarticle.py M scripts/featured.py M scripts/fixing_redirects.py M scripts/flickrripper.py M scripts/freebasemappingupload.py M scripts/harvest_template.py M scripts/illustrate_wikidata.py M scripts/image.py M scripts/imagerecat.py M scripts/imagetransfer.py M scripts/imageuncat.py M scripts/interwiki.py M scripts/isbn.py M scripts/listpages.py M scripts/login.py M scripts/lonelypages.py M scripts/maintenance/cache.py M scripts/maintenance/compat2core.py M scripts/maintenance/make_i18n_dict.py M scripts/maintenance/wikimedia_sites.py M scripts/makecat.py M scripts/match_images.py M scripts/misspelling.py M scripts/movepages.py M scripts/newitem.py M scripts/noreferences.py M scripts/nowcommons.py M scripts/pagefromfile.py M scripts/patrol.py M scripts/piper.py M scripts/protect.py M scripts/redirect.py M scripts/reflinks.py M scripts/replace.py M scripts/replicate_wiki.py M scripts/revertbot.py M scripts/script_wui.py M scripts/selflink.py M scripts/shell.py M scripts/solve_disambiguation.py M scripts/spamremove.py M scripts/states_redirect.py M scripts/template.py M scripts/templatecount.py M scripts/touch.py M scripts/transferbot.py M scripts/unlink.py M scripts/unusedfiles.py M scripts/upload.py M scripts/version.py M scripts/watchlist.py M scripts/weblinkchecker.py M scripts/welcome.py M tests/__init__.py M tests/api_tests.py M tests/archivebot_tests.py M tests/aspects.py M tests/cache_tests.py M tests/category_tests.py M tests/checkimages_tests.py M tests/data_ingestion_tests.py M tests/date_tests.py M tests/deletionbot_tests.py M tests/deprecation_tests.py M tests/dry_api_tests.py M tests/dry_site_tests.py M tests/edit_failure_tests.py M tests/exceptions_tests.py M tests/family_tests.py M tests/file_tests.py M tests/http_tests.py M tests/i18n/pywikibot.py M tests/i18n/test.py M tests/i18n_tests.py M tests/interwiki_link_tests.py M tests/ipregex_tests.py M tests/isbn_tests.py M tests/l10n_tests.py M tests/link_tests.py M tests/mediawikiversion_tests.py M tests/namespace_tests.py M tests/page_tests.py M tests/pagegenerators_tests.py M tests/protectbot_tests.py M tests/pwb/print_locals.py M tests/pwb_tests.py M tests/reflinks_tests.py M tests/script_tests.py M tests/site_tests.py M tests/tests_tests.py M tests/textlib_tests.py M tests/thread_tests.py M tests/timestamp_tests.py M tests/timestripper_tests.py M tests/tk_tests.py M tests/ui_tests.py M tests/upload_tests.py M tests/uploadbot_tests.py M tests/utils.py M tests/weblib_tests.py M tests/wikibase_edit_tests.py M tests/wikibase_tests.py M tests/wikidataquery_tests.py M tests/wikistats_tests.py M tests/xmlreader_tests.py 205 files changed, 98 insertions(+), 466 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/34/202934/1 diff --git a/pwb.py b/pwb.py index 365a22e..09d0836 100644 --- a/pwb.py +++ b/pwb.py @@ -12,7 +12,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import print_function, unicode_literals +from __future__ import print_function __version__ = '$Id$' # The following snippet was developed by Ned Batchelder (and others) @@ -57,8 +57,7 @@ # Create a module to serve as __main__ old_main_mod = sys.modules['__main__'] - # it's explicitly using str() to bypass unicode_literals in Python 2 - main_mod = types.ModuleType(str('__main__')) + main_mod = types.ModuleType('__main__') sys.modules['__main__'] = main_mod main_mod.__file__ = filename if sys.version_info[0] > 2: @@ -66,8 +65,7 @@ else: main_mod.__builtins__ = sys.modules['__builtin__'] if package: - # it's explicitly using str() to bypass unicode_literals in Python 2 - main_mod.__package__ = str(package) + main_mod.__package__ = package # Set sys.argv and the first path element properly. old_argv = sys.argv diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index db96621..d4b3081 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __release__ = '2.0b3' __version__ = '$Id$' diff --git a/pywikibot/backports.py b/pywikibot/backports.py index fbebf8f..f24100d 100644 --- a/pywikibot/backports.py +++ b/pywikibot/backports.py @@ -58,7 +58,6 @@ # # Distributed under the terms of the PSF license. # -from __future__ import unicode_literals import logging import warnings diff --git a/pywikibot/bot.py b/pywikibot/bot.py index ef8ef57..3a5ea91 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # Note: the intention is to develop this module (at some point) into a Bot @@ -361,9 +359,7 @@ ver = version.get_module_version(module) mtime = version.get_module_mtime(module) if filename and ver and mtime: - # it's explicitly using str() to bypass unicode_literals in Python 2 - # isoformat expects a char not a unicode in Python 2 - log(u' {0} {1} {2}'.format(filename, ver[:7], mtime.isoformat(str(' ')))) + log(u' {0} {1} {2}'.format(filename, ver[:7], mtime.isoformat(' '))) if config.log_pywiki_repo_version: log(u'PYWIKI REPO VERSION: %s' % version.getversion_onlinerepo()) diff --git a/pywikibot/botirc.py b/pywikibot/botirc.py index c63f4d0..e4868a1 100644 --- a/pywikibot/botirc.py +++ b/pywikibot/botirc.py @@ -11,8 +11,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # Note: the intention is to develop this module (at some point) into a Bot diff --git a/pywikibot/comms/__init__.py b/pywikibot/comms/__init__.py index 747d0a7..3b768bb 100644 --- a/pywikibot/comms/__init__.py +++ b/pywikibot/comms/__init__.py @@ -5,6 +5,4 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index 7606963..011eb59 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -11,7 +11,6 @@ - URL-encoding all data - Basic HTTP error handling """ -from __future__ import unicode_literals # # (C) Pywikibot team, 2007-2015 diff --git a/pywikibot/comms/rcstream.py b/pywikibot/comms/rcstream.py index d024bc8..fb310f9 100644 --- a/pywikibot/comms/rcstream.py +++ b/pywikibot/comms/rcstream.py @@ -8,7 +8,6 @@ This module requires socketIO_client to be installed: pip install socketIO_client """ -from __future__ import unicode_literals import sys import threading diff --git a/pywikibot/comms/threadedhttp.py b/pywikibot/comms/threadedhttp.py index 4adb427..e3c0e64 100644 --- a/pywikibot/comms/threadedhttp.py +++ b/pywikibot/comms/threadedhttp.py @@ -8,7 +8,6 @@ - HttpRequest object """ -from __future__ import unicode_literals # (C) Pywikibot team, 2007-2014 # (C) Httplib 2 team, 2006 diff --git a/pywikibot/compat/catlib.py b/pywikibot/compat/catlib.py index fe2aa55..f329b21 100644 --- a/pywikibot/compat/catlib.py +++ b/pywikibot/compat/catlib.py @@ -11,8 +11,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/pywikibot/compat/query.py b/pywikibot/compat/query.py index 13c7059..46e9976 100644 --- a/pywikibot/compat/query.py +++ b/pywikibot/compat/query.py @@ -11,8 +11,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - import pywikibot from pywikibot.data import api from pywikibot.tools import deprecated, deprecate_arg diff --git a/pywikibot/compat/userlib.py b/pywikibot/compat/userlib.py index 4ff7e78..4c999c7 100644 --- a/pywikibot/compat/userlib.py +++ b/pywikibot/compat/userlib.py @@ -11,8 +11,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/pywikibot/config2.py b/pywikibot/config2.py index dbb1c28..6e7954d 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -19,8 +19,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # @@ -30,8 +28,6 @@ import sys from warnings import warn - -from pywikibot.tools import default_encoding # This frozen set should contain all imported modules/variables, so it must # occur directly after the imports. At that point globals() only contains the @@ -907,7 +903,11 @@ _ConfigurationDeprecationWarning) # Fix up default console_encoding -console_encoding = default_encoding(console_encoding) +if console_encoding is None: + if sys.platform == 'win32': + console_encoding = 'cp850' + else: + console_encoding = 'iso-8859-1' # Fix up transliteration_target if transliteration_target == 'not set': diff --git a/pywikibot/data/__init__.py b/pywikibot/data/__init__.py index 44183c7..81fe96f 100644 --- a/pywikibot/data/__init__.py +++ b/pywikibot/data/__init__.py @@ -5,6 +5,4 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 6c13e0e..127c423 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' from collections import Container, MutableMapping @@ -1146,7 +1144,7 @@ if ip.is_IP(self.site._userinfo['name']): raise Error(u"API write action attempted as IP %r" - % str(self.site._userinfo['name'])) + % self.site._userinfo['name']) if not self.site.user(): pywikibot.warning( @@ -1465,9 +1463,10 @@ # strip the headers to get the HTTP message body if sys.version_info[0] > 2: body = container.as_bytes() + marker = b"\n\n" # separates headers from body else: body = container.as_string() - marker = b'\n\n' # separates headers from body + marker = "\n\n" # separates headers from body eoh = body.find(marker) body = body[eoh + len(marker):] # retrieve the headers from the MIME object diff --git a/pywikibot/data/wikidataquery.py b/pywikibot/data/wikidataquery.py index 2af1792..fd08839 100644 --- a/pywikibot/data/wikidataquery.py +++ b/pywikibot/data/wikidataquery.py @@ -4,13 +4,11 @@ # (C) Pywikibot team, 2013 # # Distributed under the terms of the MIT license. -from __future__ import unicode_literals import json import sys if sys.version_info[0] > 2: from urllib.parse import quote - basestring = (str, ) else: from urllib2 import quote import pickle @@ -296,7 +294,7 @@ return '"%s"' % x def validate(self): - return self.isOrContainsOnlyTypes(self.items, basestring) + return self.isOrContainsOnlyTypes(self.items, str) class Tree(Query): @@ -410,7 +408,7 @@ self.validateOrRaise() def validate(self): - return self.isOrContainsOnlyTypes(self.link, basestring) + return self.isOrContainsOnlyTypes(self.link, str) def __str__(self): return "%s[%s]" % (self.queryType, self.formatList(self.link)) diff --git a/pywikibot/data/wikistats.py b/pywikibot/data/wikistats.py index dd445c7..dee09fd 100644 --- a/pywikibot/data/wikistats.py +++ b/pywikibot/data/wikistats.py @@ -4,7 +4,6 @@ # (C) Pywikibot team, 2014 # # Distributed under the terms of the MIT license. -from __future__ import unicode_literals import sys diff --git a/pywikibot/date.py b/pywikibot/date.py index 976edef..aea18fd 100644 --- a/pywikibot/date.py +++ b/pywikibot/date.py @@ -11,7 +11,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import division, unicode_literals +from __future__ import division __version__ = '$Id$' # diff --git a/pywikibot/diff.py b/pywikibot/diff.py index 6e0e38b..9bde69f 100644 --- a/pywikibot/diff.py +++ b/pywikibot/diff.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/pywikibot/echo.py b/pywikibot/echo.py index 311827d..a7ed138 100644 --- a/pywikibot/echo.py +++ b/pywikibot/echo.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Classes and functions for working with the Echo extension.""" -from __future__ import unicode_literals import pywikibot diff --git a/pywikibot/editor.py b/pywikibot/editor.py index 7d0aa1b..7d1687d 100644 --- a/pywikibot/editor.py +++ b/pywikibot/editor.py @@ -1,7 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """Text editor class for your favourite editor.""" -from __future__ import unicode_literals # # (C) Gerrit Holl, 2004 diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py index 117165a..df3ffbd 100644 --- a/pywikibot/exceptions.py +++ b/pywikibot/exceptions.py @@ -67,8 +67,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import sys diff --git a/pywikibot/families/__init__.py b/pywikibot/families/__init__.py index ccb2305..e1d916b 100644 --- a/pywikibot/families/__init__.py +++ b/pywikibot/families/__init__.py @@ -5,6 +5,4 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/pywikibot/families/anarchopedia_family.py b/pywikibot/families/anarchopedia_family.py index e6d31fd..08ba6f3 100644 --- a/pywikibot/families/anarchopedia_family.py +++ b/pywikibot/families/anarchopedia_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Anarchopedia wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/battlestarwiki_family.py b/pywikibot/families/battlestarwiki_family.py index 954dfe3..a5fe75d 100644 --- a/pywikibot/families/battlestarwiki_family.py +++ b/pywikibot/families/battlestarwiki_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Battlestar Wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/commons_family.py b/pywikibot/families/commons_family.py index e4d8520..7eb670a 100644 --- a/pywikibot/families/commons_family.py +++ b/pywikibot/families/commons_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikimedia Commons.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/i18n_family.py b/pywikibot/families/i18n_family.py index dc75d8d..31c33e0 100644 --- a/pywikibot/families/i18n_family.py +++ b/pywikibot/families/i18n_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Translate Wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/incubator_family.py b/pywikibot/families/incubator_family.py index 5f0ad41..b57d386 100644 --- a/pywikibot/families/incubator_family.py +++ b/pywikibot/families/incubator_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Incubator Wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/lyricwiki_family.py b/pywikibot/families/lyricwiki_family.py index 0839ff9..642e573 100644 --- a/pywikibot/families/lyricwiki_family.py +++ b/pywikibot/families/lyricwiki_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for LyricWiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/mediawiki_family.py b/pywikibot/families/mediawiki_family.py index 8c9856d..fe979b0 100644 --- a/pywikibot/families/mediawiki_family.py +++ b/pywikibot/families/mediawiki_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for MediaWiki wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/meta_family.py b/pywikibot/families/meta_family.py index eeb4b27..58f7de9 100644 --- a/pywikibot/families/meta_family.py +++ b/pywikibot/families/meta_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Meta Wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/omegawiki_family.py b/pywikibot/families/omegawiki_family.py index f25c6a8..d6b4a8d 100644 --- a/pywikibot/families/omegawiki_family.py +++ b/pywikibot/families/omegawiki_family.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Omega Wiki.""" -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot import family diff --git a/pywikibot/families/osm_family.py b/pywikibot/families/osm_family.py index 5b0d198..995c8d6 100644 --- a/pywikibot/families/osm_family.py +++ b/pywikibot/families/osm_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for OpenStreetMap wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/outreach_family.py b/pywikibot/families/outreach_family.py index 8ad23b6..318dbe3 100644 --- a/pywikibot/families/outreach_family.py +++ b/pywikibot/families/outreach_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikimedia outreach wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/species_family.py b/pywikibot/families/species_family.py index 9206243..6a85925 100644 --- a/pywikibot/families/species_family.py +++ b/pywikibot/families/species_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikimedia species wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/strategy_family.py b/pywikibot/families/strategy_family.py index 3d3570c..fc33e9c 100644 --- a/pywikibot/families/strategy_family.py +++ b/pywikibot/families/strategy_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikimedia Strategy Wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/test_family.py b/pywikibot/families/test_family.py index 2a943b9..2a587c0 100644 --- a/pywikibot/families/test_family.py +++ b/pywikibot/families/test_family.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Family module for test.wikipedia.org.""" -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot import family diff --git a/pywikibot/families/vikidia_family.py b/pywikibot/families/vikidia_family.py index 07bbe7a..95e34c7 100644 --- a/pywikibot/families/vikidia_family.py +++ b/pywikibot/families/vikidia_family.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Vikidia.""" -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot import family diff --git a/pywikibot/families/wikia_family.py b/pywikibot/families/wikia_family.py index 73e0f46..7dc627a 100644 --- a/pywikibot/families/wikia_family.py +++ b/pywikibot/families/wikia_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikia.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/wikibooks_family.py b/pywikibot/families/wikibooks_family.py index 3183106..f701f01 100644 --- a/pywikibot/families/wikibooks_family.py +++ b/pywikibot/families/wikibooks_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikibooks.""" -from __future__ import unicode_literals from pywikibot import family diff --git a/pywikibot/families/wikidata_family.py b/pywikibot/families/wikidata_family.py index 181c4c4..1673439 100644 --- a/pywikibot/families/wikidata_family.py +++ b/pywikibot/families/wikidata_family.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikidata.""" -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot import family diff --git a/pywikibot/families/wikimedia_family.py b/pywikibot/families/wikimedia_family.py index b240954..1df7d81 100644 --- a/pywikibot/families/wikimedia_family.py +++ b/pywikibot/families/wikimedia_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikimedia chapter wikis.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/wikinews_family.py b/pywikibot/families/wikinews_family.py index 65aeb3b..46f18b3 100644 --- a/pywikibot/families/wikinews_family.py +++ b/pywikibot/families/wikinews_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikinews.""" -from __future__ import unicode_literals from pywikibot import family diff --git a/pywikibot/families/wikipedia_family.py b/pywikibot/families/wikipedia_family.py index c37f4a6..12333bb 100644 --- a/pywikibot/families/wikipedia_family.py +++ b/pywikibot/families/wikipedia_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikipedia.""" -from __future__ import unicode_literals from pywikibot import family diff --git a/pywikibot/families/wikiquote_family.py b/pywikibot/families/wikiquote_family.py index e7a5d76..52dfffb 100644 --- a/pywikibot/families/wikiquote_family.py +++ b/pywikibot/families/wikiquote_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikiquote.""" -from __future__ import unicode_literals from pywikibot import family diff --git a/pywikibot/families/wikisource_family.py b/pywikibot/families/wikisource_family.py index 3b8a9fa..2abbaaa 100644 --- a/pywikibot/families/wikisource_family.py +++ b/pywikibot/families/wikisource_family.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikisource.""" -from __future__ import unicode_literals - from pywikibot import family __version__ = '$Id$' diff --git a/pywikibot/families/wikitech_family.py b/pywikibot/families/wikitech_family.py index 5cba33c..4fd054e 100644 --- a/pywikibot/families/wikitech_family.py +++ b/pywikibot/families/wikitech_family.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikitech.""" -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot import family diff --git a/pywikibot/families/wikiversity_family.py b/pywikibot/families/wikiversity_family.py index 3002613..f954137 100644 --- a/pywikibot/families/wikiversity_family.py +++ b/pywikibot/families/wikiversity_family.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikiversity.""" -from __future__ import unicode_literals - from pywikibot import family __version__ = '$Id$' diff --git a/pywikibot/families/wikivoyage_family.py b/pywikibot/families/wikivoyage_family.py index 323247c..33fb2ca 100644 --- a/pywikibot/families/wikivoyage_family.py +++ b/pywikibot/families/wikivoyage_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wikivoyage.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/families/wiktionary_family.py b/pywikibot/families/wiktionary_family.py index 4e84155..374dc0a 100644 --- a/pywikibot/families/wiktionary_family.py +++ b/pywikibot/families/wiktionary_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for Wiktionary.""" -from __future__ import unicode_literals from pywikibot import family diff --git a/pywikibot/families/wowwiki_family.py b/pywikibot/families/wowwiki_family.py index b675001..6dec001 100644 --- a/pywikibot/families/wowwiki_family.py +++ b/pywikibot/families/wowwiki_family.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Family module for WOW Wiki.""" -from __future__ import unicode_literals __version__ = '$Id$' diff --git a/pywikibot/family.py b/pywikibot/family.py index cee0a29..01a6ac7 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/fixes.py b/pywikibot/fixes.py index d84788c..3261004 100644 --- a/pywikibot/fixes.py +++ b/pywikibot/fixes.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' parameter_help = u""" diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py index 2fff519..10f01c9 100644 --- a/pywikibot/i18n.py +++ b/pywikibot/i18n.py @@ -21,8 +21,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # @@ -75,8 +73,7 @@ # directories before loading the python file. try: warnings.simplefilter("ignore", ImportWarning) - # it's explicitly using str() to bypass unicode_literals in Python 2 - module = __import__(_messages_package_name, fromlist=[str('pywikibot')]) + module = __import__(_messages_package_name, fromlist=['pywikibot']) except ImportError: _messages_available = False return False @@ -311,9 +308,8 @@ # directories before loading the python file. warnings.simplefilter("ignore", ImportWarning) try: - # it's explicitly using str() to bypass unicode_literals in Python 2 transdict = getattr(__import__(_messages_package_name, - fromlist=[str(name)]), + fromlist=[name]), name).msg except ImportError as e: exception_message = str(e) diff --git a/pywikibot/interwiki_graph.py b/pywikibot/interwiki_graph.py index 68a95c7..b89f3dc 100644 --- a/pywikibot/interwiki_graph.py +++ b/pywikibot/interwiki_graph.py @@ -4,8 +4,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py index c4919cb..1a8a9bb 100644 --- a/pywikibot/logentries.py +++ b/pywikibot/logentries.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/login.py b/pywikibot/login.py index c0cc049..22a28b8 100644 --- a/pywikibot/login.py +++ b/pywikibot/login.py @@ -7,8 +7,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # import codecs diff --git a/pywikibot/page.py b/pywikibot/page.py index 0546585..25b0892 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -14,8 +14,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # @@ -273,8 +271,8 @@ def __repr__(self): """Return a more complete string representation.""" - title = self.title().encode(config.console_encoding).decode('unicode-escape') - return '{0}({1})'.format(self.__class__.__name__, title) + return "%s(%s)" % (self.__class__.__name__, + self.title().encode(config.console_encoding)) def _cmpkey(self): """ @@ -4147,7 +4145,7 @@ @rtype: bool """ if (isinstance(self.target, pywikibot.ItemPage) and - isinstance(value, basestring) and + isinstance(value, str) and self.target.id == value): return True @@ -4157,7 +4155,7 @@ return True if (isinstance(self.target, pywikibot.Coordinate) and - isinstance(value, basestring)): + isinstance(value, str)): coord_args = [float(x) for x in value.split(',')] if len(coord_args) >= 3: precision = coord_args[2] @@ -4861,7 +4859,7 @@ if unicodeCodepoint and unicodeCodepoint not in ignore: if unicodeCodepoint > sys.maxunicode: # solve narrow Python 2 build exception (UTF-16) - return eval("'\\U{:08x}'".format(unicodeCodepoint)) + return eval(r"u'\U{:08x}'".format(unicodeCodepoint)) else: return chr(unicodeCodepoint) else: diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index a98794a..f797874 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -18,8 +18,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/plural.py b/pywikibot/plural.py index c9edb6b..02a50e4 100644 --- a/pywikibot/plural.py +++ b/pywikibot/plural.py @@ -6,8 +6,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/site.py b/pywikibot/site.py index 2df0a5c..73b6a2b 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -10,8 +10,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index 410c100..69c67d8 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -11,8 +11,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py index 4157254..a311a20 100644 --- a/pywikibot/throttle.py +++ b/pywikibot/throttle.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/titletranslate.py b/pywikibot/titletranslate.py index 349c6c8..cf60b41 100644 --- a/pywikibot/titletranslate.py +++ b/pywikibot/titletranslate.py @@ -7,8 +7,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # import re diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py index b7de462..051349f 100644 --- a/pywikibot/tools/__init__.py +++ b/pywikibot/tools/__init__.py @@ -5,7 +5,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import print_function, unicode_literals +from __future__ import print_function __version__ = '$Id$' import collections @@ -403,26 +403,6 @@ while not self.finished.isSet() and not self.queue.empty(): time.sleep(0.25) self.stop() - - -def stream_encoding(stream): - """Get encoding of the stream and use a default if not existent/None.""" - try: - encoding = stream.encoding - except AttributeError: - encoding = None - return default_encoding(encoding) - - -def default_encoding(encoding): - """Return an encoding even if it's originally None.""" - if encoding is None: - if sys.platform == 'win32': - return 'cp850' - else: - return 'iso-8859-1' - else: - return encoding def itergroup(iterable, size): diff --git a/pywikibot/tools/ip.py b/pywikibot/tools/ip.py index 08c03a1..4b11c5c 100644 --- a/pywikibot/tools/ip.py +++ b/pywikibot/tools/ip.py @@ -7,8 +7,6 @@ # # Note that this module _must_ not import future.unicode_literals # otherwise it will not be able to detect the defective ipaddress module. -from __future__ import unicode_literals - __version__ = '$Id$' import re diff --git a/pywikibot/userinterfaces/__init__.py b/pywikibot/userinterfaces/__init__.py index 43eceeb..120ec4e 100644 --- a/pywikibot/userinterfaces/__init__.py +++ b/pywikibot/userinterfaces/__init__.py @@ -5,6 +5,4 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/pywikibot/userinterfaces/cgi_interface.py b/pywikibot/userinterfaces/cgi_interface.py index 42424b0..79572f7 100644 --- a/pywikibot/userinterfaces/cgi_interface.py +++ b/pywikibot/userinterfaces/cgi_interface.py @@ -1,6 +1,4 @@ """CGI user interface.""" -from __future__ import unicode_literals - import sys diff --git a/pywikibot/userinterfaces/gui.py b/pywikibot/userinterfaces/gui.py index 6ca260b..07a4ba5 100644 --- a/pywikibot/userinterfaces/gui.py +++ b/pywikibot/userinterfaces/gui.py @@ -4,7 +4,6 @@ Useful for editing the contents of an article. """ -from __future__ import unicode_literals # # (C) Rob W.W. Hooft, 2003 diff --git a/pywikibot/userinterfaces/terminal_interface.py b/pywikibot/userinterfaces/terminal_interface.py index 9a5fbf1..b0e2743 100644 --- a/pywikibot/userinterfaces/terminal_interface.py +++ b/pywikibot/userinterfaces/terminal_interface.py @@ -9,8 +9,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import sys diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py index 5a4c4b9..d6b9ba2 100755 --- a/pywikibot/userinterfaces/terminal_interface_base.py +++ b/pywikibot/userinterfaces/terminal_interface_base.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import getpass diff --git a/pywikibot/userinterfaces/terminal_interface_unix.py b/pywikibot/userinterfaces/terminal_interface_unix.py index 60d8cb2..73d577a 100755 --- a/pywikibot/userinterfaces/terminal_interface_unix.py +++ b/pywikibot/userinterfaces/terminal_interface_unix.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import sys diff --git a/pywikibot/userinterfaces/terminal_interface_win32.py b/pywikibot/userinterfaces/terminal_interface_win32.py index ddef65f..7c0dd98 100755 --- a/pywikibot/userinterfaces/terminal_interface_win32.py +++ b/pywikibot/userinterfaces/terminal_interface_win32.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import re diff --git a/pywikibot/userinterfaces/transliteration.py b/pywikibot/userinterfaces/transliteration.py index efd4103..1d8e217 100644 --- a/pywikibot/userinterfaces/transliteration.py +++ b/pywikibot/userinterfaces/transliteration.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Module to transliterate text.""" -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/pywikibot/userinterfaces/win32_unicode.py b/pywikibot/userinterfaces/win32_unicode.py index 5f7da5f..b1eca21 100755 --- a/pywikibot/userinterfaces/win32_unicode.py +++ b/pywikibot/userinterfaces/win32_unicode.py @@ -19,7 +19,7 @@ # Licensed under both CC-BY-SA and the MIT license. # ################################################ -from __future__ import print_function, unicode_literals +from __future__ import print_function from io import UnsupportedOperation import sys stdin = sys.stdin diff --git a/pywikibot/version.py b/pywikibot/version.py index d790756..5063908 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -7,8 +7,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/pywikibot/weblib.py b/pywikibot/weblib.py index 50ff23e..8f0622d 100644 --- a/pywikibot/weblib.py +++ b/pywikibot/weblib.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import sys diff --git a/pywikibot/xmlreader.py b/pywikibot/xmlreader.py index 2b77234..bf5eee3 100644 --- a/pywikibot/xmlreader.py +++ b/pywikibot/xmlreader.py @@ -13,8 +13,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # @@ -133,10 +131,7 @@ # assume it's an uncompressed XML file source = open(self.filename, 'rb') try: - # iterparse's event must be a str but they are unicode with - # unicode_literals in Python 2 - context = iterparse(source, events=(str('start'), str('end'), - str('start-ns'))) + context = iterparse(source, events=("start", "end", "start-ns")) self.root = None for event, elem in context: diff --git a/scripts/add_text.py b/scripts/add_text.py index b4b6532..ae21071 100644 --- a/scripts/add_text.py +++ b/scripts/add_text.py @@ -41,7 +41,6 @@ # This is a script to add a template to the top of the pages with # category:catname # Warning! Put it in one line, otherwise it won't work correctly. -from __future__ import unicode_literals python add_text.py -cat:catname -summary:"Bot: Adding a template" -text:"{{Something}}" -except:"\{\{([Tt]emplate:|)[Ss]omething" -up diff --git a/scripts/archivebot.py b/scripts/archivebot.py index 22d9af7..2506408 100644 --- a/scripts/archivebot.py +++ b/scripts/archivebot.py @@ -92,8 +92,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # import datetime diff --git a/scripts/basic.py b/scripts/basic.py index b6d73be..33d6319 100755 --- a/scripts/basic.py +++ b/scripts/basic.py @@ -20,8 +20,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py index bb416c7..a012eb4 100755 --- a/scripts/blockpageschecker.py +++ b/scripts/blockpageschecker.py @@ -54,8 +54,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/blockreview.py b/scripts/blockreview.py index d78c9f9..ec8f8ea 100644 --- a/scripts/blockreview.py +++ b/scripts/blockreview.py @@ -19,8 +19,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/capitalize_redirects.py b/scripts/capitalize_redirects.py index 01746de..42fe6c1 100644 --- a/scripts/capitalize_redirects.py +++ b/scripts/capitalize_redirects.py @@ -29,8 +29,6 @@ # # Automatically converted from compat branch by compat2core.py script # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/casechecker.py b/scripts/casechecker.py index 27be8e0..4a9a684 100644 --- a/scripts/casechecker.py +++ b/scripts/casechecker.py @@ -6,7 +6,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import print_function, unicode_literals +from __future__ import print_function __version__ = '$Id$' import os diff --git a/scripts/catall.py b/scripts/catall.py index c70ece8..8585c91 100755 --- a/scripts/catall.py +++ b/scripts/catall.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + """ This script shows the categories on each page and lets you change them. @@ -22,8 +23,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/category.py b/scripts/category.py index 1342d45..0c1a3c4 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -108,8 +108,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py index 7860d67..c68c8c7 100755 --- a/scripts/category_redirect.py +++ b/scripts/category_redirect.py @@ -20,13 +20,12 @@ Usage: category_redirect.py [options] """ + # # (C) Pywikibot team, 2008-2014 # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # import sys diff --git a/scripts/cfd.py b/scripts/cfd.py index 16d5c24..53a49aa 100644 --- a/scripts/cfd.py +++ b/scripts/cfd.py @@ -14,8 +14,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/checkimages.py b/scripts/checkimages.py index a477953..9e3377d 100644 --- a/scripts/checkimages.py +++ b/scripts/checkimages.py @@ -76,6 +76,7 @@ * Add a report for the image tagged. """ + # # (C) Kyle/Orgullomoore, 2006-2007 (newimage.py) # (C) Siebrand Mazeland, 2007-2010 @@ -84,8 +85,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/claimit.py b/scripts/claimit.py index 099d9a2..b1a968d 100755 --- a/scripts/claimit.py +++ b/scripts/claimit.py @@ -54,8 +54,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py index 9d42220..597b0a2 100755 --- a/scripts/clean_sandbox.py +++ b/scripts/clean_sandbox.py @@ -45,7 +45,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import division, unicode_literals +from __future__ import division __version__ = '$Id$' # diff --git a/scripts/commons_link.py b/scripts/commons_link.py index c8ca521..fae8aa5 100644 --- a/scripts/commons_link.py +++ b/scripts/commons_link.py @@ -29,7 +29,7 @@ # Ported by Geoffrey "GEOFBOT" Mon for Google Code-In 2013 # User:Sn1per # -from __future__ import unicode_literals + __version__ = '$Id$' diff --git a/scripts/commonscat.py b/scripts/commonscat.py index 75beea1..957983c 100755 --- a/scripts/commonscat.py +++ b/scripts/commonscat.py @@ -25,30 +25,35 @@ For example to go through all categories: commonscat.py -start:Category:! """ -# Commonscat bot: -# -# Take a page. Follow the interwiki's and look for the commonscat template -# *Found zero templates. Done. -# *Found one template. Add this template -# *Found more templates. Ask the user <- still have to implement this -# -# TODO: -# *Update interwiki's at commons -# *Collect all possibilities also if local wiki already has link. -# *Better support for other templates (translations) / redundant templates. -# *Check mode, only check pages which already have the template -# *More efficient like interwiki.py -# *Possibility to update other languages in the same run -# -# Porting notes: -# -# *Ported from compat to core -# *Replaced now-deprecated Page methods -# *Fixed way of finding interlanguage links in findCommonscatLink() -# *Removed unused and now possibly broken updateInterwiki() method -# -# Ported by Allen Guo <[email protected]> -# November 2013 +""" +Commonscat bot: + +Take a page. Follow the interwiki's and look for the commonscat template +*Found zero templates. Done. +*Found one template. Add this template +*Found more templates. Ask the user <- still have to implement this + +TODO: +*Update interwiki's at commons +*Collect all possibilities also if local wiki already has link. +*Better support for other templates (translations) / redundant templates. +*Check mode, only check pages which already have the template +*More efficient like interwiki.py +*Possibility to update other languages in the same run +""" + +""" +Porting notes: + +*Ported from compat to core +*Replaced now-deprecated Page methods +*Fixed way of finding interlanguage links in findCommonscatLink() +*Removed unused and now possibly broken updateInterwiki() method + +Ported by Allen Guo <[email protected]> +November 2013 +""" + # # (C) Multichill, 2008-2009 # (C) Xqt, 2009-2015 @@ -56,8 +61,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/coordinate_import.py b/scripts/coordinate_import.py index 22541c1..6074ba3 100644 --- a/scripts/coordinate_import.py +++ b/scripts/coordinate_import.py @@ -26,8 +26,6 @@ # # Distributed under the terms of MIT License. # -from __future__ import unicode_literals - __version__ = '$Id$' # import pywikibot diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py index 14e88fb..b04acb8 100755 --- a/scripts/cosmetic_changes.py +++ b/scripts/cosmetic_changes.py @@ -70,8 +70,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/create_categories.py b/scripts/create_categories.py index ba5ab06..b3d0f59 100755 --- a/scripts/create_categories.py +++ b/scripts/create_categories.py @@ -28,8 +28,6 @@ to create [[Category:Cultural heritage monuments in Hensies]]. """ -from __future__ import unicode_literals - __version__ = '$Id$' # # (C) Multichill, 2011 diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py index c30669e..1e44ece 100755 --- a/scripts/data_ingestion.py +++ b/scripts/data_ingestion.py @@ -10,8 +10,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/delete.py b/scripts/delete.py index 2b0ed2a..e6fb2f1 100644 --- a/scripts/delete.py +++ b/scripts/delete.py @@ -30,8 +30,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/disambredir.py b/scripts/disambredir.py index e1b2db9..af697bb 100644 --- a/scripts/disambredir.py +++ b/scripts/disambredir.py @@ -15,8 +15,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # import re diff --git a/scripts/editarticle.py b/scripts/editarticle.py index ca7b850..97656d9 100755 --- a/scripts/editarticle.py +++ b/scripts/editarticle.py @@ -27,8 +27,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/featured.py b/scripts/featured.py index ed6347d..b5957a6 100644 --- a/scripts/featured.py +++ b/scripts/featured.py @@ -61,8 +61,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py index 6fbe7bd..aabbd78 100644 --- a/scripts/fixing_redirects.py +++ b/scripts/fixing_redirects.py @@ -19,8 +19,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # import re diff --git a/scripts/flickrripper.py b/scripts/flickrripper.py index 38e97df..433ee2a 100644 --- a/scripts/flickrripper.py +++ b/scripts/flickrripper.py @@ -15,7 +15,6 @@ #**Add a nice hotcat lookalike for the adding of categories #**Filter the categories #*Upload the image -from __future__ import unicode_literals Todo: *Check if the image is already uploaded (SHA hash) diff --git a/scripts/freebasemappingupload.py b/scripts/freebasemappingupload.py index 5722da6..bbacec6 100644 --- a/scripts/freebasemappingupload.py +++ b/scripts/freebasemappingupload.py @@ -13,14 +13,13 @@ -filename: the filename to read the freebase-wikidata mappings from; default: fb2w.nt.gz """ + # # (C) Denny Vrandecic, 2013 # (C) Pywikibot team, 2013-2014 # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py index c131a23..d5e0d64 100755 --- a/scripts/harvest_template.py +++ b/scripts/harvest_template.py @@ -26,8 +26,6 @@ # # Distributed under the terms of MIT License. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/illustrate_wikidata.py b/scripts/illustrate_wikidata.py index cc1e4e2..c6c5518 100644 --- a/scripts/illustrate_wikidata.py +++ b/scripts/illustrate_wikidata.py @@ -18,8 +18,6 @@ # # Distributed under the terms of MIT License. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/image.py b/scripts/image.py index c66c586..08efc95 100644 --- a/scripts/image.py +++ b/scripts/image.py @@ -38,8 +38,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # import pywikibot diff --git a/scripts/imagerecat.py b/scripts/imagerecat.py index 73a60b3..b911148 100644 --- a/scripts/imagerecat.py +++ b/scripts/imagerecat.py @@ -30,8 +30,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index 9592c60..94a1739 100644 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -30,8 +30,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import re diff --git a/scripts/imageuncat.py b/scripts/imageuncat.py index e553851..acc6087 100755 --- a/scripts/imageuncat.py +++ b/scripts/imageuncat.py @@ -12,8 +12,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/interwiki.py b/scripts/interwiki.py index aa3d46a..41b4a67 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -342,8 +342,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/isbn.py b/scripts/isbn.py index b9b118e..2d5ed9d 100755 --- a/scripts/isbn.py +++ b/scripts/isbn.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- + """ This script reports and fixes invalid ISBN numbers. @@ -39,8 +40,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/listpages.py b/scripts/listpages.py index 6c64157..55da78b 100644 --- a/scripts/listpages.py +++ b/scripts/listpages.py @@ -77,8 +77,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/login.py b/scripts/login.py index 1e87a4e..8d52556 100755 --- a/scripts/login.py +++ b/scripts/login.py @@ -52,8 +52,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/lonelypages.py b/scripts/lonelypages.py index 72b06fb..af36aa1 100644 --- a/scripts/lonelypages.py +++ b/scripts/lonelypages.py @@ -37,8 +37,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py index 4a0d1d2..2b84d3c 100644 --- a/scripts/maintenance/cache.py +++ b/scripts/maintenance/cache.py @@ -42,7 +42,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import print_function, unicode_literals +from __future__ import print_function __version__ = '$Id$' # diff --git a/scripts/maintenance/compat2core.py b/scripts/maintenance/compat2core.py index fb9ef6c..386d509 100644 --- a/scripts/maintenance/compat2core.py +++ b/scripts/maintenance/compat2core.py @@ -27,8 +27,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/maintenance/make_i18n_dict.py b/scripts/maintenance/make_i18n_dict.py index c685618..711c3d4 100644 --- a/scripts/maintenance/make_i18n_dict.py +++ b/scripts/maintenance/make_i18n_dict.py @@ -27,8 +27,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py index 57b7e5e..83f2080 100644 --- a/scripts/maintenance/wikimedia_sites.py +++ b/scripts/maintenance/wikimedia_sites.py @@ -6,8 +6,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/makecat.py b/scripts/makecat.py index e1ca9b3..b92cbd3 100644 --- a/scripts/makecat.py +++ b/scripts/makecat.py @@ -31,13 +31,12 @@ R(emove) - remove a page that is already in the list L(ist) - show current list of pages to include or to check """ + # (C) Andre Engels, 2004 # (C) Pywikibot team, 2005-2014 # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/match_images.py b/scripts/match_images.py index d74b715..915d1be 100644 --- a/scripts/match_images.py +++ b/scripts/match_images.py @@ -29,7 +29,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import division, unicode_literals +from __future__ import division __version__ = '$Id$' diff --git a/scripts/misspelling.py b/scripts/misspelling.py index e0d7b36..a18a7e4 100644 --- a/scripts/misspelling.py +++ b/scripts/misspelling.py @@ -20,13 +20,12 @@ -main only check pages in the main namespace, not in the talk, wikipedia, user, etc. namespaces. """ + # (C) Daniel Herding, 2007 # (C) Pywikibot team, 2007-2014 # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/movepages.py b/scripts/movepages.py index 300f2e0..59edd26 100644 --- a/scripts/movepages.py +++ b/scripts/movepages.py @@ -38,8 +38,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/newitem.py b/scripts/newitem.py index fcf3873..eac1b05 100644 --- a/scripts/newitem.py +++ b/scripts/newitem.py @@ -24,8 +24,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/noreferences.py b/scripts/noreferences.py index 3fa562a..ed79be3 100755 --- a/scripts/noreferences.py +++ b/scripts/noreferences.py @@ -38,8 +38,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py index ac41e39..a6df733 100644 --- a/scripts/nowcommons.py +++ b/scripts/nowcommons.py @@ -54,8 +54,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py index 94cd310..9f28900 100644 --- a/scripts/pagefromfile.py +++ b/scripts/pagefromfile.py @@ -53,8 +53,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/patrol.py b/scripts/patrol.py index 540bc42..b347c1f 100644 --- a/scripts/patrol.py +++ b/scripts/patrol.py @@ -22,8 +22,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot from pywikibot import pagegenerators, Bot diff --git a/scripts/piper.py b/scripts/piper.py index b015a0c..b12f21f 100644 --- a/scripts/piper.py +++ b/scripts/piper.py @@ -33,8 +33,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/protect.py b/scripts/protect.py index 47b5bb2..c5d259a 100644 --- a/scripts/protect.py +++ b/scripts/protect.py @@ -39,6 +39,7 @@ Unprotect all pages listed in text file 'unprotect.txt' without prompting. python protect.py -file:unprotect.txt -unprotect -always """ + # # Written by https://it.wikisource.org/wiki/Utente:Qualc1 # Created by modifying delete.py @@ -47,8 +48,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/redirect.py b/scripts/redirect.py index 65ac41b..c29fa88 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -73,8 +73,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/reflinks.py b/scripts/reflinks.py index 79fbbd7..70d6426 100644 --- a/scripts/reflinks.py +++ b/scripts/reflinks.py @@ -41,7 +41,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import division, unicode_literals +from __future__ import division __version__ = '$Id$' # diff --git a/scripts/replace.py b/scripts/replace.py index 44f8ecb..5c57a4f 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -122,8 +122,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py index aef3948..41d7a11 100644 --- a/scripts/replicate_wiki.py +++ b/scripts/replicate_wiki.py @@ -41,8 +41,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/revertbot.py b/scripts/revertbot.py index abd3fbf..4f99c73 100644 --- a/scripts/revertbot.py +++ b/scripts/revertbot.py @@ -21,8 +21,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/script_wui.py b/scripts/script_wui.py index 052d721..fd6e792 100755 --- a/scripts/script_wui.py +++ b/scripts/script_wui.py @@ -58,8 +58,6 @@ # ... # --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/selflink.py b/scripts/selflink.py index bcd284c..734cf39 100644 --- a/scripts/selflink.py +++ b/scripts/selflink.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- + """ This bot searches for selflinks and allows removing them. @@ -15,7 +16,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals import re import pywikibot diff --git a/scripts/shell.py b/scripts/shell.py index a5de43b..0a0add6 100644 --- a/scripts/shell.py +++ b/scripts/shell.py @@ -17,8 +17,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py index 60d4149..c740a58 100644 --- a/scripts/solve_disambiguation.py +++ b/scripts/solve_disambiguation.py @@ -75,8 +75,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/spamremove.py b/scripts/spamremove.py index c728e9b..0f8303e 100755 --- a/scripts/spamremove.py +++ b/scripts/spamremove.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- + """ Script to remove links that are being or have been spammed. @@ -22,13 +23,12 @@ multiple times it will search all given namespaces """ + # # (C) Pywikibot team, 2007-2014 # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/states_redirect.py b/scripts/states_redirect.py index de8ddc8..f184df5 100644 --- a/scripts/states_redirect.py +++ b/scripts/states_redirect.py @@ -1,5 +1,6 @@ #!usr/bin/python # -*- coding: utf-8 -*- + """Create country sub-division redirect pages. Check if they are in the form Something, State, and if so, create a redirect @@ -19,8 +20,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/template.py b/scripts/template.py index f145fdc..741c865 100755 --- a/scripts/template.py +++ b/scripts/template.py @@ -105,8 +105,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/templatecount.py b/scripts/templatecount.py index 5751641..9ca5120 100644 --- a/scripts/templatecount.py +++ b/scripts/templatecount.py @@ -36,8 +36,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import datetime diff --git a/scripts/touch.py b/scripts/touch.py index 42d112e..8048a57 100755 --- a/scripts/touch.py +++ b/scripts/touch.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- + """ This bot goes over multiple pages of a wiki, and edits them without changes. @@ -20,8 +21,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/transferbot.py b/scripts/transferbot.py index 61dfbfd..8b9cbcf 100644 --- a/scripts/transferbot.py +++ b/scripts/transferbot.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- + """ This script transfers pages from a source wiki to a target wiki. @@ -24,8 +25,6 @@ # Transfer all pages in category "Query service" from the Toolserver wiki to # wikitech, adding Nova_Resource:Tools/Tools/ as prefix -from __future__ import unicode_literals - transferbot.py -v -family:toolserver -tofamily:wikitech -cat:"Query service" -prefix:Nova_Resource:Tools/Tools/ # Copy the template "Query service" from the Toolserver wiki to wikitech diff --git a/scripts/unlink.py b/scripts/unlink.py index 103a9a0..403d626 100755 --- a/scripts/unlink.py +++ b/scripts/unlink.py @@ -25,8 +25,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py index 61957a1..7307368 100644 --- a/scripts/unusedfiles.py +++ b/scripts/unusedfiles.py @@ -8,6 +8,7 @@ -always Don't be asked every time. """ + # # (C) Leonardo Gregianin, 2007 # (C) Filnik, 2008 @@ -16,8 +17,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/upload.py b/scripts/upload.py index 0412b9b..5afd564 100755 --- a/scripts/upload.py +++ b/scripts/upload.py @@ -37,8 +37,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/version.py b/scripts/version.py index 17d0b4b..fb43be1 100755 --- a/scripts/version.py +++ b/scripts/version.py @@ -8,8 +8,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/watchlist.py b/scripts/watchlist.py index 447858a..9873992 100755 --- a/scripts/watchlist.py +++ b/scripts/watchlist.py @@ -21,8 +21,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py index 9faf7f9..968d763 100644 --- a/scripts/weblinkchecker.py +++ b/scripts/weblinkchecker.py @@ -88,14 +88,13 @@ python weblinkchecker.py -repeat Loads all wiki pages where dead links were found during a prior run """ + # # (C) Daniel Herding, 2005 # (C) Pywikibot team, 2005-2014 # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import re diff --git a/scripts/welcome.py b/scripts/welcome.py index 16403be..ed327cf 100644 --- a/scripts/welcome.py +++ b/scripts/welcome.py @@ -177,8 +177,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/__init__.py b/tests/__init__.py index 031b90d..96672a4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import os diff --git a/tests/api_tests.py b/tests/api_tests.py index ad44b6b..d827f9c 100644 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import datetime diff --git a/tests/archivebot_tests.py b/tests/archivebot_tests.py index 4379c96..5c57d54 100644 --- a/tests/archivebot_tests.py +++ b/tests/archivebot_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' from datetime import datetime diff --git a/tests/aspects.py b/tests/aspects.py index 1fb1728..c6ff682 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -11,7 +11,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import print_function, unicode_literals +from __future__ import print_function __version__ = '$Id$' """ TODO: diff --git a/tests/cache_tests.py b/tests/cache_tests.py index b5e6fed..020dd1e 100644 --- a/tests/cache_tests.py +++ b/tests/cache_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/category_tests.py b/tests/category_tests.py index df7fc19..d9d543c 100644 --- a/tests/category_tests.py +++ b/tests/category_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot diff --git a/tests/checkimages_tests.py b/tests/checkimages_tests.py index f033a88..4c0b10e 100644 --- a/tests/checkimages_tests.py +++ b/tests/checkimages_tests.py @@ -1,7 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """Unit tests for checkimages script.""" -from __future__ import unicode_literals from scripts import checkimages diff --git a/tests/data_ingestion_tests.py b/tests/data_ingestion_tests.py index 8a26978..909889c 100644 --- a/tests/data_ingestion_tests.py +++ b/tests/data_ingestion_tests.py @@ -1,8 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -"""Unit tests for data_ingestion.py script.""" -from __future__ import unicode_literals +"""Unit tests for data_ingestion.py script.""" __version__ = '$Id$' import os diff --git a/tests/date_tests.py b/tests/date_tests.py index 178da8f..c7058ed 100644 --- a/tests/date_tests.py +++ b/tests/date_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - from datetime import datetime from pywikibot import date @@ -47,8 +45,7 @@ return testMapEntry for formatname in date.formats: - # it's explicitly using str() because __name__ must be str - test_name = str('test_' + formatname) + test_name = "test_" + formatname dct[test_name] = test_method(formatname) dct[test_name].__name__ = test_name return type.__new__(cls, name, bases, dct) diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py index c1050df..1a8d5ed 100644 --- a/tests/deletionbot_tests.py +++ b/tests/deletionbot_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot diff --git a/tests/deprecation_tests.py b/tests/deprecation_tests.py index eccac70..699ffcb 100644 --- a/tests/deprecation_tests.py +++ b/tests/deprecation_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot.tools import ( diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py index 82d35af..f895be7 100644 --- a/tests/dry_api_tests.py +++ b/tests/dry_api_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py index 4e28476..3efa3f3 100644 --- a/tests/dry_site_tests.py +++ b/tests/dry_site_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py index 01b163d..a13c330 100644 --- a/tests/edit_failure_tests.py +++ b/tests/edit_failure_tests.py @@ -12,8 +12,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot diff --git a/tests/exceptions_tests.py b/tests/exceptions_tests.py index 9fa8041..9f3e250 100644 --- a/tests/exceptions_tests.py +++ b/tests/exceptions_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot diff --git a/tests/family_tests.py b/tests/family_tests.py index 24e9c95..d32a3c4 100644 --- a/tests/family_tests.py +++ b/tests/family_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot.family import Family diff --git a/tests/file_tests.py b/tests/file_tests.py index 625df91..8fa1de5 100644 --- a/tests/file_tests.py +++ b/tests/file_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot diff --git a/tests/http_tests.py b/tests/http_tests.py index 3453d4b..ff8337c 100644 --- a/tests/http_tests.py +++ b/tests/http_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import os diff --git a/tests/i18n/pywikibot.py b/tests/i18n/pywikibot.py index f0c1382..a8650f3 100644 --- a/tests/i18n/pywikibot.py +++ b/tests/i18n/pywikibot.py @@ -1,5 +1,3 @@ # -*- coding: utf-8 -*- """i18n message bundle called 'pywikibot' to fool the i18n loader.""" -from __future__ import unicode_literals - msg = {} diff --git a/tests/i18n/test.py b/tests/i18n/test.py index 315224a..44afee0 100644 --- a/tests/i18n/test.py +++ b/tests/i18n/test.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Test i18n data.""" -from __future__ import unicode_literals - msg = { 'de': { 'test-plural': u'Bot: Ändere %(num)d {{PLURAL:num|Seite|Seiten}}.', diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py index c116abb..5c05011 100644 --- a/tests/i18n_tests.py +++ b/tests/i18n_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import sys diff --git a/tests/interwiki_link_tests.py b/tests/interwiki_link_tests.py index 0ddee67..d5b44fb 100644 --- a/tests/interwiki_link_tests.py +++ b/tests/interwiki_link_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot import config2 as config diff --git a/tests/ipregex_tests.py b/tests/ipregex_tests.py index 7553684..098fdc7 100644 --- a/tests/ipregex_tests.py +++ b/tests/ipregex_tests.py @@ -5,8 +5,6 @@ # (C) Pywikibot team, 2014 # # Distributed under the terms of the MIT license. -from __future__ import unicode_literals - __version__ = '$Id$' from pywikibot.tools import ip diff --git a/tests/isbn_tests.py b/tests/isbn_tests.py index b871903..26ec753 100644 --- a/tests/isbn_tests.py +++ b/tests/isbn_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - import pywikibot __version__ = '$Id$' diff --git a/tests/l10n_tests.py b/tests/l10n_tests.py index 2dbe1c8..d3dc417 100644 --- a/tests/l10n_tests.py +++ b/tests/l10n_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import re diff --git a/tests/link_tests.py b/tests/link_tests.py index 461dc88..ab80d0d 100644 --- a/tests/link_tests.py +++ b/tests/link_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot diff --git a/tests/mediawikiversion_tests.py b/tests/mediawikiversion_tests.py index 125a257..17bd115 100644 --- a/tests/mediawikiversion_tests.py +++ b/tests/mediawikiversion_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py index 6f18a73..4b497f2 100644 --- a/tests/namespace_tests.py +++ b/tests/namespace_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' from collections import Iterable @@ -205,14 +203,14 @@ a.defaultcontentmodel = 'bar' s = repr(a) - r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], defaultcontentmodel=%r)" \ - % (unicode('Foo'), unicode('Foo'), unicode('bar')) + r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], defaultcontentmodel='bar')" \ + % (unicode('Foo'), unicode('Foo')) self.assertEqual(s, r) a.case = 'upper' s = repr(a) - r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], case=%r, defaultcontentmodel=%r)" \ - % (unicode('Foo'), unicode('Foo'), unicode('upper'), unicode('bar')) + r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], case='upper', defaultcontentmodel='bar')" \ + % (unicode('Foo'), unicode('Foo')) self.assertEqual(s, r) b = eval(repr(a)) diff --git a/tests/page_tests.py b/tests/page_tests.py index 44b1d42..d170cab 100644 --- a/tests/page_tests.py +++ b/tests/page_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import sys diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py index d504e25..35e6320 100755 --- a/tests/pagegenerators_tests.py +++ b/tests/pagegenerators_tests.py @@ -5,8 +5,6 @@ # (C) Pywikibot team, 2014 # # Distributed under the terms of the MIT license. -from __future__ import unicode_literals - __version__ = '$Id$' import datetime diff --git a/tests/protectbot_tests.py b/tests/protectbot_tests.py index 260ac6a..df7d56b 100644 --- a/tests/protectbot_tests.py +++ b/tests/protectbot_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot diff --git a/tests/pwb/print_locals.py b/tests/pwb/print_locals.py index c39b776..42749df 100644 --- a/tests/pwb/print_locals.py +++ b/tests/pwb/print_locals.py @@ -1,5 +1,4 @@ """Script that forms part of pwb_tests.""" -from __future__ import unicode_literals import os.path diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py index fe52837..e4c0285 100644 --- a/tests/pwb_tests.py +++ b/tests/pwb_tests.py @@ -11,8 +11,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import os diff --git a/tests/reflinks_tests.py b/tests/reflinks_tests.py index fec7c44..042c29f 100644 --- a/tests/reflinks_tests.py +++ b/tests/reflinks_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import os diff --git a/tests/script_tests.py b/tests/script_tests.py index dd44df3..fb47dea 100644 --- a/tests/script_tests.py +++ b/tests/script_tests.py @@ -5,7 +5,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import print_function, unicode_literals +from __future__ import print_function __version__ = '$Id$' import os @@ -306,8 +306,6 @@ test_name = 'test__' + script_name + '_help' else: test_name = 'test_' + script_name + '_help' - # it's explicitly using str() because __name__ must be str - test_name = str(test_name) dct[test_name] = test_execution(script_name, ['-help']) if script_name in ['version', 'script_wui', # Failing on travis-ci @@ -328,8 +326,6 @@ test_name = 'test__' + script_name + '_simulate' else: test_name = 'test_' + script_name + '_simulate' - # it's explicitly using str() because __name__ must be str - test_name = str(test_name) dct[test_name] = test_execution(script_name, ['-simulate'], no_args_expected_results) if script_name in ['catall', # stdout user interaction diff --git a/tests/site_tests.py b/tests/site_tests.py index 274c282..23ad897 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/tests/tests_tests.py b/tests/tests_tests.py index c95c57d..6ac9c69 100755 --- a/tests/tests_tests.py +++ b/tests/tests_tests.py @@ -5,8 +5,6 @@ # (C) Pywikibot team, 2014 # # Distributed under the terms of the MIT license. -from __future__ import unicode_literals - __version__ = '$Id$' import pywikibot diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index 6baae06..3d9c2a3 100644 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import codecs diff --git a/tests/thread_tests.py b/tests/thread_tests.py index 326a606..581aab0 100644 --- a/tests/thread_tests.py +++ b/tests/thread_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' from tests.aspects import unittest, TestCase diff --git a/tests/timestamp_tests.py b/tests/timestamp_tests.py index 1b449d4..362247b 100644 --- a/tests/timestamp_tests.py +++ b/tests/timestamp_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import calendar diff --git a/tests/timestripper_tests.py b/tests/timestripper_tests.py index 3573bb9..54af2a0 100644 --- a/tests/timestripper_tests.py +++ b/tests/timestripper_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import datetime diff --git a/tests/tk_tests.py b/tests/tk_tests.py index 8fc10af..efa21a9 100644 --- a/tests/tk_tests.py +++ b/tests/tk_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' diff --git a/tests/ui_tests.py b/tests/ui_tests.py index 20e8204..087a230 100644 --- a/tests/ui_tests.py +++ b/tests/ui_tests.py @@ -5,6 +5,7 @@ # # Distributed under the terms of the MIT license. # + # NOTE FOR RUNNING WINDOWS UI TESTS # # Windows UI tests have to be run using the tests\ui_tests.bat helper script. @@ -24,8 +25,6 @@ # easy_install --upgrade https://pywinauto.googlecode.com/files/pywinauto-0.4.2.zip # # -from __future__ import unicode_literals - __version__ = '$Id$' import logging @@ -138,19 +137,6 @@ newstdout = strout._stream newstderr = strerr._stream newstdin = strin._stream - -if sys.version_info[0] == 2: - # In Python 2 the sys.std* streams use bytes instead of unicode - # But this module is using unicode_literals so '…' will generate unicode - # So it'll convert those back into bytes - original_write = newstdin.write - - def encoded_write(text): - if isinstance(text, unicode): - text = text.encode('utf8') - original_write(text) - - newstdin.write = encoded_write org_print = ui._print org_input = ui._raw_input diff --git a/tests/upload_tests.py b/tests/upload_tests.py index 4d1b1ea..628362b 100644 --- a/tests/upload_tests.py +++ b/tests/upload_tests.py @@ -9,8 +9,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import os diff --git a/tests/uploadbot_tests.py b/tests/uploadbot_tests.py index b7e2de2..a84667c 100644 --- a/tests/uploadbot_tests.py +++ b/tests/uploadbot_tests.py @@ -9,8 +9,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/utils.py b/tests/utils.py index 99c0957..ae80633 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -5,7 +5,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import print_function, unicode_literals +from __future__ import print_function __version__ = '$Id$' # import os @@ -16,7 +16,7 @@ from warnings import warn import pywikibot -from pywikibot.tools import SelfCallDict, stream_encoding +from pywikibot.tools import SelfCallDict from pywikibot.site import Namespace from pywikibot.data.api import CachedRequest from pywikibot.data.api import Request as _original_Request @@ -258,6 +258,11 @@ @param command: executable to run and arguments to use @type command: list of unicode """ + def decode(stream): + if sys.version_info[0] > 2: + return stream.decode(pywikibot.config.console_encoding) + else: + return stream env = os.environ.copy() # sys.path may have been modified by the test runner to load dependencies. env['PYTHONPATH'] = ":".join(sys.path) @@ -278,12 +283,10 @@ p = subprocess.Popen(command, env=env, **options) - stdin_encoding = stream_encoding(p.stdin) - stdout_encoding = stream_encoding(p.stdout) - stderr_encoding = stream_encoding(p.stderr) - if data_in is not None: - p.stdin.write(data_in.encode(stdin_encoding)) + if sys.version_info[0] > 2: + data_in = data_in.encode(pywikibot.config.console_encoding) + p.stdin.write(data_in) p.stdin.flush() # _communicate() otherwise has a broken pipe stderr_lines = b'' @@ -296,7 +299,7 @@ if error: line = p.stderr.readline() stderr_lines += line - if error in line.decode(stdout_encoding): + if error in decode(line): break time.sleep(1) waited += 1 @@ -309,8 +312,8 @@ data_out = p.communicate() return {'exit_code': p.returncode, - 'stdout': data_out[0].decode(stdout_encoding), - 'stderr': (stderr_lines + data_out[1]).decode(stderr_encoding)} + 'stdout': decode(data_out[0]), + 'stderr': decode(stderr_lines + data_out[1])} def execute_pwb(args, data_in=None, timeout=0, error=None): diff --git a/tests/weblib_tests.py b/tests/weblib_tests.py index d05c853..84f445f 100644 --- a/tests/weblib_tests.py +++ b/tests/weblib_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import sys diff --git a/tests/wikibase_edit_tests.py b/tests/wikibase_edit_tests.py index 84dc056..9094e53 100644 --- a/tests/wikibase_edit_tests.py +++ b/tests/wikibase_edit_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py index 5a37136..f3bf135 100644 --- a/tests/wikibase_tests.py +++ b/tests/wikibase_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/wikidataquery_tests.py b/tests/wikidataquery_tests.py index 6254126..04266c5 100644 --- a/tests/wikidataquery_tests.py +++ b/tests/wikidataquery_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/wikistats_tests.py b/tests/wikistats_tests.py index 6a2dca0..deda834 100644 --- a/tests/wikistats_tests.py +++ b/tests/wikistats_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' # diff --git a/tests/xmlreader_tests.py b/tests/xmlreader_tests.py index bee3cb5..85dbbe8 100644 --- a/tests/xmlreader_tests.py +++ b/tests/xmlreader_tests.py @@ -5,8 +5,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import unicode_literals - __version__ = '$Id$' import os.path -- To view, visit https://gerrit.wikimedia.org/r/202934 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3dcf96b96727a63b874d983484247539885a1bff Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: XZise <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
