jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/682781 )
Change subject: [cleanup] Rename config2
......................................................................
[cleanup] Rename config2
This file is called 'config2.py' because it conflicted with a file by the same
name in compat [1][2]. That is no longer a concern so we can rename this to the
name we import as.
Importing 'pywikibot.config2' still works, just deprecated.
[2]
https://www.mediawiki.org/wiki/Special:Code/pywikipedia/6062
[1]
https://gerrit.wikimedia.org/r/plugins/gitiles/pywikibot/compat/+/refs/head…
Change-Id: I74cbb1bc609a105245d0edc66e20e78339ec31d4
---
M docs/api_ref/pywikibot.rst
M generate_user_files.py
M pwb.py
M pywikibot/CONTENT.rst
M pywikibot/__init__.py
M pywikibot/bot.py
M pywikibot/comms/http.py
R pywikibot/config.py
M pywikibot/data/mysql.py
M pywikibot/exceptions.py
M pywikibot/i18n.py
M pywikibot/interwiki_graph.py
M pywikibot/userinterfaces/terminal_interface_base.py
M pywikibot/version.py
M scripts/maintenance/cache.py
M scripts/version.py
M tests/aspects.py
M tests/http_tests.py
M tests/interwiki_link_tests.py
M tests/link_tests.py
M tests/page_tests.py
M tests/ui_tests.py
M tox.ini
23 files changed, 54 insertions(+), 56 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/api_ref/pywikibot.rst b/docs/api_ref/pywikibot.rst
index 05b3f0b..bbfec20 100644
--- a/docs/api_ref/pywikibot.rst
+++ b/docs/api_ref/pywikibot.rst
@@ -35,10 +35,10 @@
.. automodule:: pywikibot.bot_choice
-pywikibot.config2 module
-------------------------
+pywikibot.config module
+-----------------------
-.. automodule:: pywikibot.config2
+.. automodule:: pywikibot.config
pywikibot.cosmetic\_changes module
----------------------------------
diff --git a/generate_user_files.py b/generate_user_files.py
index 1de6e43..3ac55ab 100755
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -33,8 +33,8 @@
# Disable user-config usage as we are creating it here
pywikibot = _import_with_no_user_config('pywikibot')
-config, __url__ = pywikibot.config2, pywikibot.__url__
-base_dir = pywikibot.config2.base_dir
+config, __url__ = pywikibot.config, pywikibot.__url__
+base_dir = pywikibot.config.base_dir
try:
console_encoding = sys.stdout.encoding
@@ -68,14 +68,14 @@
pywikibot.output('Using existing directory')
else:
try:
- os.mkdir(new_base, pywikibot.config2.private_files_permission)
+ os.mkdir(new_base, pywikibot.config.private_files_permission)
except Exception as e:
pywikibot.error('directory creation failed: {0}'.format(e))
continue
pywikibot.output('Created new directory.')
break
- if new_base == pywikibot.config2.get_base_dir(new_base):
+ if new_base == pywikibot.config.get_base_dir(new_base):
# config would find that file
return new_base
@@ -114,7 +114,7 @@
@return: The family, language and username
@rtype: tuple of three str
"""
- known_families = sorted(pywikibot.config2.family_files.keys())
+ known_families = sorted(pywikibot.config.family_files.keys())
if default_family not in known_families:
default_family = None
fam = pywikibot.bot.input_list_choice(
@@ -216,9 +216,9 @@
def parse_sections():
- """Parse sections from config2.py file.
+ """Parse sections from config.py file.
- config2.py will be in the pywikibot/ directory relative to this
+ config.py will be in the pywikibot/ directory relative to this
generate_user_files script.
@return: a list of ConfigSection named tuples.
@@ -228,7 +228,7 @@
ConfigSection = namedtuple('ConfigSection', 'head, info, section')
install = os.path.dirname(os.path.abspath(__file__))
- with codecs.open(os.path.join(install, 'pywikibot', 'config2.py'),
+ with codecs.open(os.path.join(install, 'pywikibot', 'config.py'),
'r', 'utf-8') as config_f:
config_file = config_f.read()
diff --git a/pwb.py b/pwb.py
index 1d20d0e..3e14281 100755
--- a/pwb.py
+++ b/pwb.py
@@ -191,8 +191,8 @@
# Search for user-config.py before creating one.
# If successful, user-config.py already exists in one of the candidate
-# directories. See config2.py for details on search order.
-# Use env var to communicate to config2.py pwb.py location (bug T74918).
+# directories. See config.py for details on search order.
+# Use env var to communicate to config.py pwb.py location (bug T74918).
_pwb_dir = os.path.split(__file__)[0]
os.environ['PYWIKIBOT_DIR_PWB'] = _pwb_dir
try:
diff --git a/pywikibot/CONTENT.rst b/pywikibot/CONTENT.rst
index 978079f..10ae2c3 100644
--- a/pywikibot/CONTENT.rst
+++ b/pywikibot/CONTENT.rst
@@ -17,7 +17,7 @@
+----------------------------+------------------------------------------------------+
| bot_choice.py | Classes for input_choice
|
+----------------------------+------------------------------------------------------+
- | config2.py | Module to define and load Pywikibot configuration
|
+ | config.py | Module to define and load Pywikibot configuration
|
+----------------------------+------------------------------------------------------+
| cosmetic_changes.py | Slight modifications to a wiki page's source code
|
+----------------------------+------------------------------------------------------+
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index b282396..7ec3875 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -19,7 +19,7 @@
from warnings import warn
import pywikibot.exceptions
-from pywikibot import config2 as config
+from pywikibot import config as _config
from pywikibot.__metadata__ import (
__copyright__,
__description__,
@@ -116,7 +116,7 @@
'__maintainer__', '__maintainer_email__', '__name__',
'__url__', '__version__',
'Bot', 'calledModuleName', 'CaptchaError',
'CascadeLockedPage',
- 'Category', 'CircularRedirect', 'Claim', 'config',
'Coordinate',
+ 'Category', 'CircularRedirect', 'Claim',
'Coordinate',
'CoordinateGlobeUnknownException', 'critical',
'CurrentPageBot', 'debug',
'EditConflict', 'error', 'Error', 'exception',
'FatalServerError',
'FilePage', 'handle_args', 'html2unicode', 'input',
'input_choice',
@@ -1105,7 +1105,7 @@
matched_sites = []
# Iterate through all families and look, which does apply to
# the given URL
- for fam in config.family_files:
+ for fam in _config.family_files:
family = Family.load(fam)
code = family.from_url(url)
if code is not None:
@@ -1165,8 +1165,8 @@
fam, _, code = code.partition(':')
else:
# Fallback to config defaults
- code = code or config.mylang
- fam = fam or config.family
+ code = code or _config.mylang
+ fam = fam or _config.family
if not isinstance(fam, Family):
fam = Family.load(fam)
@@ -1177,9 +1177,9 @@
family_name = str(fam)
code_to_user = {}
- if '*' in config.usernames: # T253127: usernames is a defaultdict
- code_to_user = config.usernames['*'].copy()
- code_to_user.update(config.usernames[family_name])
+ if '*' in _config.usernames: # T253127: usernames is a defaultdict
+ code_to_user = _config.usernames['*'].copy()
+ code_to_user.update(_config.usernames[family_name])
user = user or code_to_user.get(code) or code_to_user.get('*')
if not isinstance(interface, type):
@@ -1282,7 +1282,7 @@
remainingPages -= 1
remainingSeconds = datetime.timedelta(
- seconds=round(remainingPages * config.put_throttle))
+ seconds=round(remainingPages * _config.put_throttle))
return (remainingPages, remainingSeconds)
if stop:
@@ -1290,7 +1290,7 @@
page_put_queue.put((None, [], {}))
num, sec = remaining()
- if num > 0 and sec.total_seconds() > config.noisysleep:
+ if num > 0 and sec.total_seconds() > _config.noisysleep:
output(color_format(
'{lightblue}Waiting for {num} pages to be put. '
'Estimated time remaining: {sec}{default}', num=num, sec=sec))
@@ -1343,9 +1343,9 @@
# queue to hold pending requests
-page_put_queue = Queue(config.max_queue_size)
+page_put_queue = Queue(_config.max_queue_size)
# queue to signal that async_manager is working on a request. See T147178.
-page_put_queue_busy = Queue(config.max_queue_size)
+page_put_queue_busy = Queue(_config.max_queue_size)
# set up the background thread
_putthread = threading.Thread(target=async_manager)
# identification for debugging purposes
@@ -1353,6 +1353,8 @@
_putthread.setDaemon(True)
wrapper = _ModuleDeprecationWrapper(__name__)
+wrapper._add_deprecated_attr('config2',
replacement_name='pywikibot.config',
+ since='20210426', future_warning=True)
wrapper._add_deprecated_attr('__release__', __version__,
replacement_name='pywikibot.__version__',
since='20200707')
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index f694c00..a6c4c61 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -102,8 +102,7 @@
from warnings import warn
import pywikibot
-from pywikibot import config2 as config
-from pywikibot import daemonize, i18n, version
+from pywikibot import config, daemonize, i18n, version
from pywikibot.backports import Dict, Iterable, List, Sequence
from pywikibot.bot_choice import (
AlwaysChoice,
@@ -409,7 +408,7 @@
log('SYSTEM: {}'.format(os.uname()))
# config file dir
- log('CONFIG FILE DIR: {}'.format(pywikibot.config2.base_dir))
+ log('CONFIG FILE DIR: {}'.format(pywikibot.config.base_dir))
all_modules = sys.modules.keys()
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 4b52e35..b35a7f0 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -29,7 +29,7 @@
import requests
import pywikibot
-from pywikibot import config2 as config
+from pywikibot import config
from pywikibot.backports import Tuple
from pywikibot.exceptions import (
FatalServerError,
diff --git a/pywikibot/config2.py b/pywikibot/config.py
similarity index 99%
rename from pywikibot/config2.py
rename to pywikibot/config.py
index 1e8985b..a32bfe1 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config.py
@@ -434,7 +434,7 @@
# Get the names of all known families, and initialize with empty dictionaries.
-# ‘families/’ is a subdirectory of the directory in which config2.py is found.
+# ‘families/’ is a subdirectory of the directory in which config.py is found.
register_families_folder(os.path.join(os.path.dirname(__file__), 'families'))
# Set to True to override the {{bots}} exclusion protocol (at your own risk!)
diff --git a/pywikibot/data/mysql.py b/pywikibot/data/mysql.py
index 907457e..79f4bc3 100644
--- a/pywikibot/data/mysql.py
+++ b/pywikibot/data/mysql.py
@@ -9,7 +9,7 @@
import pkg_resources
import pywikibot
-from pywikibot import config2 as config
+from pywikibot import config
from pywikibot.tools import deprecated_args
@@ -46,7 +46,7 @@
if None, config.verbose_output will be used.
@return: generator which yield tuples
"""
- # These are specified in config2.py or user-config.py
+ # These are specified in config.py or user-config.py
if verbose is None:
verbose = config.verbose_output
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 019f337..48c85ed 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -149,7 +149,7 @@
UserWarning: warnings targeted at users
- - config2._ConfigurationDeprecationWarning: user configuration file problems
+ - config._ConfigurationDeprecationWarning: user configuration file problems
- login._PasswordFileWarning: password file problems
- ArgumentDeprecationWarning: command line argument problems
- FamilyMaintenanceWarning: missing information in family definition
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 42fcbda..39f424e 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -32,8 +32,7 @@
import pywikibot
import pywikibot.exceptions
-from pywikibot import __url__
-from pywikibot import config2 as config
+from pywikibot import __url__, config
from pywikibot.backports import List, cache
from pywikibot.plural import plural_rule
from pywikibot.tools import (
diff --git a/pywikibot/interwiki_graph.py b/pywikibot/interwiki_graph.py
index 8faa414..ddd1de8 100644
--- a/pywikibot/interwiki_graph.py
+++ b/pywikibot/interwiki_graph.py
@@ -10,7 +10,7 @@
from typing import Optional
import pywikibot
-from pywikibot import config2 as config
+from pywikibot import config
from pywikibot.tools import ModuleDeprecationWrapper
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py
b/pywikibot/userinterfaces/terminal_interface_base.py
index 106edbf..4c6dee2 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -12,7 +12,7 @@
from typing import Any, Optional, Union
import pywikibot
-from pywikibot import config2 as config
+from pywikibot import config
from pywikibot.backports import Sequence
from pywikibot.bot_choice import (
ChoiceException,
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 96b1d03..ddf4543 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -21,7 +21,7 @@
from warnings import warn
import pywikibot
-from pywikibot import config2 as config
+from pywikibot import config
from pywikibot.backports import cache
from pywikibot.comms.http import fetch
from pywikibot.exceptions import VersionParseError
diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py
index 7c6d78b..a7a242f 100755
--- a/scripts/maintenance/cache.py
+++ b/scripts/maintenance/cache.py
@@ -227,7 +227,7 @@
- True = always use
"""
if not cache_path:
- cache_path = os.path.join(pywikibot.config2.base_dir,
+ cache_path = os.path.join(pywikibot.config.base_dir,
'apicache-py{0:d}'.format(PYTHON_VERSION[0]))
if not os.path.exists(cache_path):
@@ -436,13 +436,13 @@
cache_paths += [os.path.join('tests', f) for f in folders]
# Also process the base directory, if it isn't the current directory
- if os.path.abspath(os.getcwd()) != pywikibot.config2.base_dir:
+ if os.path.abspath(os.getcwd()) != pywikibot.config.base_dir:
cache_paths += [
- os.path.join(pywikibot.config2.base_dir, f) for f in folders]
+ os.path.join(pywikibot.config.base_dir, f) for f in folders]
# Also process the user home cache, if it isn't the config directory
userpath = os.path.expanduser(os.path.join('~', '.pywikibot'))
- if userpath != pywikibot.config2.base_dir:
+ if userpath != pywikibot.config.base_dir:
cache_paths += [
os.path.join(userpath, f) for f in folders]
diff --git a/scripts/version.py b/scripts/version.py
index c0da3e8..a11faf2 100755
--- a/scripts/version.py
+++ b/scripts/version.py
@@ -68,8 +68,8 @@
os.environ.get(environ_name,
'Not set')))
- pywikibot.output('Config base dir: ' + pywikibot.config2.base_dir)
- for family, usernames in pywikibot.config2.usernames.items():
+ pywikibot.output('Config base dir: ' + pywikibot.config.base_dir)
+ for family, usernames in pywikibot.config.usernames.items():
if not usernames:
continue
pywikibot.output('Usernames for family "{0}":'.format(family))
diff --git a/tests/aspects.py b/tests/aspects.py
index 5831ab7..e3eb391 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -23,8 +23,7 @@
from unittest.util import safe_repr
import pywikibot
-import pywikibot.config2 as config
-from pywikibot import Site
+from pywikibot import Site, config
from pywikibot.backports import removeprefix
from pywikibot.comms import http
from pywikibot.data.api import Request as _original_Request
diff --git a/tests/http_tests.py b/tests/http_tests.py
index fed76e2..2bd4256 100644
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -13,7 +13,7 @@
import requests
import pywikibot
-from pywikibot import config2 as config
+from pywikibot import config
from pywikibot.comms import http
from pywikibot.exceptions import FatalServerError, Server504Error
from pywikibot.tools import PYTHON_VERSION, suppress_warnings
diff --git a/tests/interwiki_link_tests.py b/tests/interwiki_link_tests.py
index 196c80e..bc30396 100644
--- a/tests/interwiki_link_tests.py
+++ b/tests/interwiki_link_tests.py
@@ -6,7 +6,7 @@
#
from contextlib import suppress
-from pywikibot import config2 as config
+from pywikibot import config
from pywikibot.exceptions import InvalidTitleError
from pywikibot.page import Link
from tests.aspects import AlteredDefaultSiteTestCase as LinkTestCase
diff --git a/tests/link_tests.py b/tests/link_tests.py
index e9a0530..52e0433 100644
--- a/tests/link_tests.py
+++ b/tests/link_tests.py
@@ -8,8 +8,7 @@
from contextlib import suppress
import pywikibot
-from pywikibot import Site
-from pywikibot import config2 as config
+from pywikibot import Site, config
from pywikibot.exceptions import InvalidTitleError, SiteDefinitionError
from pywikibot.page import Link, Page, SiteLink
from pywikibot.site import Namespace
diff --git a/tests/page_tests.py b/tests/page_tests.py
index f63cdab..2baa0e6 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -186,7 +186,7 @@
maintalk = mainpage.toggleTalkPage()
family_name = (site.family.name + ':'
- if pywikibot.config2.family != site.family.name
+ if pywikibot.config.family != site.family.name
else '')
self.assertEqual(str(mainpage), '[[{}{}:{}]]'
.format(family_name, site.code,
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index c6c9cad..9310526 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -732,12 +732,12 @@
def setUp(self):
"""Force colorized_output to True."""
super().setUp()
- self._old_config = pywikibot.config2.colorized_output
- pywikibot.config2.colorized_output = True
+ self._old_config = pywikibot.config.colorized_output
+ pywikibot.config.colorized_output = True
def tearDown(self):
"""Undo colorized_output configuration."""
- pywikibot.config2.colorized_output = self._old_config
+ pywikibot.config.colorized_output = self._old_config
super().tearDown()
diff --git a/tox.ini b/tox.ini
index 6500f3c..82304f3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -131,7 +131,7 @@
pywikibot/_wbtypes.py: N802
pywikibot/backports.py: F401
pywikibot/bot.py: N802, N816
- pywikibot/config2.py: N816
+ pywikibot/config.py: N816
pywikibot/cosmetic_changes.py : N802, N803, N806, N816
pywikibot/data/api.py : N802
pywikibot/date.py : N802, N803, N806, N816
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/682781
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I74cbb1bc609a105245d0edc66e20e78339ec31d4
Gerrit-Change-Number: 682781
Gerrit-PatchSet: 6
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Isaacandy <isaac(a)iznd.xyz>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-CC: Legoktm <legoktm(a)debian.org>
Gerrit-MessageType: merged