jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Provide global -config option to specify the user config file name

- add get_user_config_file() function to config.py
- add config_file parameter to config.get_base_dir() function
- add -config option to pywikibot.handle_args() function
- update documentation

Bug: T317311
Change-Id: I7c83d4000fea160b602261f740936689aa224aca
---
M pwb.py
M pywikibot/bot.py
M pywikibot/config.py
M pywikibot/cosmetic_changes.py
M pywikibot/data/mysql.py
M pywikibot/editor.py
M pywikibot/exceptions.py
M pywikibot/login.py
M pywikibot/page/_pages.py
M pywikibot/scripts/__init__.py
M pywikibot/scripts/generate_user_files.py
M pywikibot/scripts/login.py
M pywikibot/site/_apisite.py
M pywikibot/site_detect.py
M pywikibot/specialbots/_upload.py
M scripts/__init__.py
M scripts/interwiki.py
M scripts/replicate_wiki.py
M scripts/watchlist.py
M scripts/weblinkchecker.py
M tests/pwb_tests.py
M user-config.py.sample
22 files changed, 181 insertions(+), 134 deletions(-)

diff --git a/pwb.py b/pwb.py
index 2c9a9a6..e5f354f 100755
--- a/pwb.py
+++ b/pwb.py
@@ -4,8 +4,8 @@

This wrapper script invokes script by its name in this search order:

-1. Scripts listed in `user_script_paths` list inside your `user-config.py`
- settings file in the given order. Refer
+1. Scripts listed in `user_script_paths` list inside your user config
+ settings file (usually `user-config.py`) in the given order. Refer
:ref:`External Script Path Settings`.
2. User scripts residing in `scripts/userscripts` (directory mode only).
3. Scripts residing in `scripts` folder (directory mode only).
@@ -260,22 +260,27 @@

filename, script_args, global_args = handle_args(*sys.argv)

-# Search for user-config.py before creating one.
-# If successful, user-config.py already exists in one of the candidate
+# Search for user config file (user-config.py) before creating one.
+# If successful, user config file already exists in one of the candidate
# 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:
import pywikibot as pwb
-except RuntimeError: # pragma: no cover
+except RuntimeError as e: # pragma: no cover
os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '2'
import pywikibot as pwb

- # user-config.py to be created
+ # user config file to be created
if filename is not None and not (filename.startswith('generate_')
or filename == 'version.py'):
- print("NOTE: 'user-config.py' was not found!")
+ from pywikibot.config import user_config_file
+ if user_config_file != 'user-config.py':
+ # do not create a user config file if name is not default
+ sys.exit(e)
+
+ print('NOTE: user-config.py was not found!')
print('Please follow the prompts to create it:')
run_python_file(os.path.join(
_pwb_dir, 'pywikibot', 'scripts', 'generate_user_files.py'), [])
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 9720398..6aaa9f0 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -195,20 +195,22 @@
==============
(Global arguments available for all bots)

--dir:PATH Read the bot's configuration data from directory given by
- PATH, instead of from the default directory.
+-dir:PATH Read the bot's configuration data from directory given
+ by PATH, instead of from the default directory.

--lang:xx Set the language of the wiki you want to work on, overriding
- the configuration in user-config.py. xx should be the
- site code.
+-config:xyn The user config filename. Default is user-config.py.
+
+-lang:xx Set the language of the wiki you want to work on,
+ overriding the configuration in user config file.
+ xx should be the site code.

-family:xyz Set the family of the wiki you want to work on, e.g.
- wikipedia, wiktionary, wikivoyage, ...
- This will override the configuration in user-config.py.
+ wikipedia, wiktionary, wikivoyage, ... This will
+ override the configuration in user config file.

-site:xyz:xx Set the wiki site you want to work on, e.g.
- wikipedia:test, wiktionary:de, wikivoyage:en, ...
- This will override the configuration in user-config.py.
+ wikipedia:test, wiktionary:de, wikivoyage:en, ... This
+ will override the configuration in user config file.

-user:xyz Log in as user 'xyz' instead of the default username.

@@ -226,24 +228,24 @@

-nolog Disable the log file (if it is enabled by default).

--maxlag Sets a new maxlag parameter to a number of seconds. Defer bot
- edits during periods of database server lag. Default is set
- by config.py
+-maxlag Sets a new maxlag parameter to a number of seconds.
+ Defer bot edits during periods of database server lag.
+ Default is set by config.py

--putthrottle:n Set the minimum time (in seconds) the bot will wait between
--pt:n saving pages.
+-putthrottle:n Set the minimum time (in seconds) the bot will wait
+-pt:n between saving pages.
-put_throttle:n

--debug:item Enable the log file and include extensive debugging data
--debug for component "item" (for all components if the second form
- is used).
+-debug:item Enable the log file and include extensive debugging
+-debug data for component "item" (for all components if the
+ second form is used).

-verbose Have the bot provide additional console output that may be
-v useful in debugging.

-cosmeticchanges Toggles the cosmetic_changes setting made in config.py
--cc or user-config.py to its inverse and overrules it. All
- other settings and restrictions are untouched. The
+-cc or user config file to its inverse and overrules it.
+ All other settings and restrictions are untouched. The
setting may also be given directly like `-cc:True`;
accepted values for the option are `1`, `yes`, `true`,
`on`, `y`, `t` for True and `0`, `no`, `false`, `off`,
@@ -255,8 +257,8 @@
An integer or float value may be given to simulate a
processing time; the bot just waits for given seconds.

--<config var>:n You may use all given numeric config variables as option and
- modify it with command line.
+-<config var>:n You may use all given numeric config variables as
+ option and modify it with command line.

"""

@@ -849,18 +851,35 @@
def handle_args(args: Optional[Iterable[str]] = None,
do_help: bool = True) -> List[str]:
"""
- Handle standard command line arguments, and return the rest as a list.
+ Handle global command line arguments and return the rest as a list.

- Takes the command line arguments as strings, processes all global
- parameters such as -lang or -log, initialises the logging layer,
- which emits startup information into log at level 'verbose'.
+ Takes the command line arguments as strings, processes all
+ :ref:`global parameters<global options>` such as ``-lang`` or
+ ``-log``, initialises the logging layer, which emits startup
+ information into log at level 'verbose'. This function makes sure
+ that global arguments are applied first, regardless of the order in
+ which the arguments were given. ``args`` may be passed as an
+ argument, thereby overriding ``sys.argv``.

- This makes sure that global arguments are applied first,
- regardless of the order in which the arguments were given.
+ >>> local_args = pywikibot.handle_args() # sys.argv is used
+ >>> local_args # doctest: +SKIP
+ []
+ >>> local_args = pywikibot.handle_args(['-simulate', '-myoption'])
+ >>> local_args # global optons are handled, show the remaining
+ ['-myoption']
+ >>> for arg in local_args: pass # do whatever is wanted with local_args

- args may be passed as an argument, thereby overriding sys.argv
+ .. versionchanged:: 5.2
+ *-site* global option was added
+ .. versionchanged:: 7.1
+ *-cosmetic_changes* and *-cc* may be set directly instead of
+ toggling the value. Refer :func:`tools.strtobool` for valid values.
+ .. versionchanged:: 7.7
+ *-config* global option was added.

- :param args: Command line arguments
+ :param args: Command line arguments. If None,
+ :meth:`pywikibot.argvu<userinterfaces._interface_base.ABUIC.argvu>`
+ is used which is a copy of ``sys.argv``
:param do_help: Handle parameter '-help' to show help and invoke sys.exit
:return: list of arguments not recognised globally
"""
@@ -886,7 +905,8 @@
option, _, value = arg.partition(':')
if do_help_val is not False and option == '-help':
do_help_val = value or True
- elif option == '-dir':
+ # these are handled by config.py
+ elif option in ('-config', '-dir'):
pass
elif option == '-site':
config.family, config.mylang = value.split(':')
diff --git a/pywikibot/config.py b/pywikibot/config.py
index 7207fec..536e2e0 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -5,21 +5,23 @@
which may be located in directory specified by the environment variable
`PYWIKIBOT_DIR`, or the same directory as `pwb.py`, or in a directory
within the users home. See :py:obj:`get_base_dir` for more information.
+The different file name can specified with global `-config` option.

-If user-config.py cannot be found in any of those locations, this module
-will fail to load unless the environment variable `PYWIKIBOT_NO_USER_CONFIG`
-is set to a value other than `'0'`. i.e. `PYWIKIBOT_NO_USER_CONFIG=1` will
-allow config to load without a `user-config.py`. However, warnings will be
-shown if `user-config.py` was not loaded. To prevent these warnings, set
-`PYWIKIBOT_NO_USER_CONFIG=2`. If Pywikibot is installed as a site-package
-the behaviour is like `PYWIKIBOT_NO_USER_CONFIG=2` is set.
+If user config file cannot be found in any of those locations, this
+module will fail to load unless the environment variable
+`PYWIKIBOT_NO_USER_CONFIG` is set to a value other than `'0'`. i.e.
+`PYWIKIBOT_NO_USER_CONFIG=1` will allow config to load without a user
+config file. However, warnings will be shown if a user config file was
+not loaded. To prevent these warnings, set `PYWIKIBOT_NO_USER_CONFIG=2`.
+If Pywikibot is installed as a site-package the behaviour is like
+`PYWIKIBOT_NO_USER_CONFIG=2` is set.

-Functions made available to `user-config`:
+Functions made available to user config file:

- user_home_path

-Sets module global base_dir and provides utility methods to
-build paths relative to base_dir:
+Sets module global `base_dir` and `user_config_file` and provides
+utility methods to build paths relative to base_dir:

- makepath
- datafilepath
@@ -90,14 +92,14 @@


# IMPORTANT:
-# Do not change any of the variables in this file. Instead, make
-# a file user-config.py, and overwrite values in there.
+# Do not change any of the variables in this file. Instead, make a
+# user config file (user-config.py), and overwrite values in there.

-# Note: all variables defined in this module are made available to bots as
-# configuration settings, *except* variable names beginning with an
+# Note: all variables defined in this module are made available to bots
+# as configuration settings, *except* variable names beginning with an
# underscore (example: _variable). Be sure to use an underscore on any
-# variables that are intended only for internal use and not to be exported
-# to other modules.
+# variables that are intended only for internal use and not to be
+# exported to other modules.

_private_values = {'authenticate', 'db_password'}
_deprecated_variables = {
@@ -129,7 +131,7 @@

# The dictionary usernames should contain a username for each site where you
# have a bot account. Please set your usernames by adding such lines to your
-# user-config.py:
+# user config file (user-config.py):
#
# usernames['wikipedia']['de'] = 'myGermanUsername'
# usernames['wiktionary']['en'] = 'myEnglishUsername'
@@ -185,9 +187,9 @@
# exception CaptchaError being thrown if a captcha is encountered.
solve_captcha = True

-# Some sites will require password authentication to access the HTML pages at
-# the site. If you have any such site, add lines to your user-config.py of
-# the following form:
+# Some sites will require password authentication to access the HTML
+# pages at the site. If you have any such site, add lines to your user
+# config file of the following form:
#
# authenticate['en.wikipedia.org'] = ('John','XXXXX')
# authenticate['*.wikipedia.org'] = ('John','XXXXX')
@@ -205,7 +207,7 @@
# Pywikibot also support OAuth 1.0a via mwoauth
# https://pypi.org/project/mwoauth
#
-# You can add OAuth tokens to your user-config.py of the following form:
+# You can add OAuth tokens to your user config file of this form:
#
# authenticate['en.wikipedia.org'] = ('consumer_key','consumer_secret',
# 'access_key', 'access_secret')
@@ -279,7 +281,22 @@
return os.path.join(os.path.expanduser('~'), path)


-def get_base_dir(test_directory: Optional[str] = None) -> str:
+def get_user_config_file() -> str:
+ """Return user config file name.
+
+ .. versionadded:: 7.7
+ """
+ for arg in sys.argv[1:]:
+ opt, _, value = arg.partition(':')
+ if opt == '-config':
+ if not value.endswith('.py'):
+ value += '.py'
+ return value
+ return 'user-config.py'
+
+
+def get_base_dir(test_directory: Optional[str] = None,
+ config_file: str = 'user-config.py') -> str:
r"""Return the directory in which user-specific information is stored.

This is determined in the following order:
@@ -296,18 +313,22 @@
`'.pywikibot'` directory (Unix and similar) under the user's
home directory.

- Set `PYWIKIBOT_NO_USER_CONFIG=1` to disable loading `user-config.py`
- or install Pywikibot as a site-package.
+ Set `PYWIKIBOT_NO_USER_CONFIG=1` to disable loading user config file
+ (`user-config.py`) or install Pywikibot as a site-package.
+
+ .. versionchanged:: 7.7
+ Added the *config_file* parameter.

:param test_directory: Assume that a user config file exists in this
directory. Used to test whether placing a user config file in this
directory will cause it to be selected as the base directory.
+ :param config_file: filename of the user config file
"""
def exists(directory: str) -> bool:
directory = os.path.abspath(directory)
if directory == test_directory:
return True
- return os.path.exists(os.path.join(directory, 'user-config.py'))
+ return os.path.exists(os.path.join(directory, config_file))

if test_directory is not None:
test_directory = os.path.abspath(test_directory)
@@ -358,18 +379,17 @@
# make sure this path is valid and that it contains user-config file
if not os.path.isdir(base_dir):
raise RuntimeError("Directory '{}' does not exist.".format(base_dir))
- # check if user-config.py is in base_dir
+ # check if config_file is in base_dir
if not exists(base_dir):
- exc_text = 'No user-config.py found in directory {!r}.\n'.format(
- base_dir)
+ exc_text = 'No {} found in directory {!r}.\n'.format(
+ config_file, base_dir)

if __no_user_config is None:
assert get_base_dir.__doc__ is not None
exc_text += (
- ' Please check that user-config.py is stored in the correct '
- 'location.\n'
- ' Directory where user-config.py is searched is determined '
- 'as follows:\n\n ') + get_base_dir.__doc__
+ ' Please check that {0} is stored in the correct location.\n'
+ ' Directory where {0} is searched is determined as follows:'
+ '\n\n '.format(config_file)) + get_base_dir.__doc__
raise RuntimeError(exc_text)

if __no_user_config != '2':
@@ -378,12 +398,15 @@
return base_dir


+user_config_file = get_user_config_file()
+
# Save base_dir for use by other modules
-base_dir = get_base_dir()
+base_dir = get_base_dir(config_file=user_config_file)

for arg in sys.argv[1:]:
if arg.startswith('-verbose') or arg == '-v':
output('The base directory is ' + base_dir)
+ output('The user config file is ' + user_config_file)
break
family_files = {}

@@ -648,7 +671,7 @@
# Supported formats include png, jpg, ps, and svg. See:
# http://www.graphviz.org/doc/info/output.html
# If you want to also dump the dot files, you can use this in your
-# user-config.py:
+# user config file:
# interwiki_graph_formats = ['dot', 'png']
# If you need a PNG image with an HTML image map, use this:
# interwiki_graph_formats = ['png', 'cmap']
@@ -785,7 +808,7 @@
# The dictionary cosmetic_changes_enable should contain a tuple of languages
# for each site where you wish to enable in addition to your own langlanguage
# (if cosmetic_changes_mylang_only is set)
-# Please set your dictionary by adding such lines to your user-config.py:
+# Please set your dictionary by adding such lines to your user config file:
# cosmetic_changes_enable['wikipedia'] = ('de', 'en', 'fr')
cosmetic_changes_enable = {} # type: Dict[str, Tuple[str, ...]]

@@ -793,13 +816,13 @@
# for each site where you wish to disable cosmetic changes. You may use it with
# cosmetic_changes_mylang_only is False, but you can also disable your own
# language. This also overrides the settings in the cosmetic_changes_enable
-# dictionary. Please set your dict by adding such lines to your user-config.py:
+# dictionary. Please set your dict by adding such lines to your user config:
# cosmetic_changes_disable['wikipedia'] = ('de', 'en', 'fr')
cosmetic_changes_disable = {} # type: Dict[str, Tuple[str, ...]]

# cosmetic_changes_deny_script is a list of scripts for which cosmetic changes
# are disabled. You may add additional scripts by appending script names in
-# your user-config.py ("+=" operator is strictly recommended):
+# your user config file ("+=" operator is strictly recommended):
# cosmetic_changes_deny_script += ['your_script_name_1', 'your_script_name_2']
# Appending the script name also works:
# cosmetic_changes_deny_script.append('your_script_name')
@@ -807,7 +830,7 @@
'newitem', 'touch']

# ############# REPLICATION BOT SETTINGS ################
-# You can add replicate_replace to your user-config.py.
+# You can add replicate_replace to your user config file.
#
# Use has the following format:
#
@@ -826,7 +849,7 @@
# Defines what additional actions the bots are NOT allowed to do (e.g. 'edit')
# on the wiki server. Allows simulation runs of bots to be carried out without
# changing any page on the server side. Use this setting to add more actions
-# in user-config.py for wikis with extra write actions.
+# into user config file for wikis with extra write actions.
actions_to_block = [] # type: List[str]

# Set simulate to True or use -simulate option to block all actions given
@@ -956,7 +979,7 @@
_exec_globals = copy.deepcopy(_public_globals)

# Always try to get the user files
-_filename = os.path.join(base_dir, 'user-config.py')
+_filename = os.path.join(base_dir, user_config_file)
if os.path.exists(_filename):
_filestatus = os.stat(_filename)
_filemode = _filestatus[0]
@@ -969,7 +992,7 @@
else:
warning('Skipped {fn!r}: writeable by others.'.format(fn=_filename))
elif __no_user_config and __no_user_config != '2':
- warning('user-config.py cannot be loaded.')
+ warning('{} cannot be loaded.'.format(user_config_file))


class _DifferentTypeError(UserWarning, TypeError):
@@ -984,8 +1007,8 @@
) -> None:
super().__init__(
'Configuration variable "{}" is defined as "{}" in '
- 'your user-config.py but expected "{}".'
- .format(name, actual_type.__name__,
+ 'your {} but expected "{}".'
+ .format(name, actual_type.__name__, user_config_file,
'", "'.join(t.__name__ for t in allowed_types)))


@@ -1015,9 +1038,9 @@


DEPRECATED_VARIABLE = (
- '"{}" present in our user-config.py is no longer a supported '
- 'configuration variable and should be removed. Please inform the '
- 'maintainers if you depend on it.')
+ '"{{}}" present in our {} is no longer a supported configuration variable '
+ 'and should be removed. Please inform the maintainers if you depend on it.'
+ .format(user_config_file))


def _check_user_config_types(
@@ -1044,9 +1067,9 @@
_ConfigurationDeprecationWarning)
elif name not in _future_variables:
warn('\n' + fill('Configuration variable "{}" is defined in '
- 'your user-config.py but unknown. It can be '
- 'a misspelled one or a variable that is no '
- 'longer supported.'.format(name)),
+ 'your {} but unknown. It can be a misspelled '
+ 'one or a variable that is no longer '
+ 'supported.'.format(name, user_config_file)),
UserWarning)


diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 6fea918..29d7517 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -7,7 +7,7 @@

scripts/cosmetic_changes.py

-For regular use, it is recommended to put this line into your user-config.py::
+For regular use, it is recommended to put this line into your user config::

cosmetic_changes = True

@@ -15,7 +15,7 @@
dictionary cosmetic_changes_enable to your user-config.py. It should contain
a tuple of languages for each site where you wish to enable in addition to
your own langlanguage if cosmetic_changes_mylang_only is True (see below).
-Please set your dictionary by adding such lines to your user-config.py::
+Please set your dictionary by adding such lines to your user config::

cosmetic_changes_enable['wikipedia'] = ('de', 'en', 'fr')

@@ -26,13 +26,14 @@
if you're running a bot on multiple sites and want to do cosmetic changes on
all of them, but be careful if you do.

-You may disable cosmetic changes by adding the all unwanted languages to the
-dictionary cosmetic_changes_disable in your user-config.py. It should contain
-a tuple of languages for each site where you wish to disable cosmetic changes.
-You may use it with cosmetic_changes_mylang_only is False, but you can also
-disable your own language. This also overrides the settings in the dictionary
-cosmetic_changes_enable. Please set this dictionary by adding such lines to
-your user-config.py::
+You may disable cosmetic changes by adding the all unwanted languages to
+the `dictionary cosmetic_changes_disable` in your user config file
+(`user_config.py`). It should contain a tuple of languages for each site
+where you wish to disable cosmetic changes. You may use it with
+`cosmetic_changes_mylang_only` is False, but you can also disable your
+own language. This also overrides the settings in the dictionary
+`cosmetic_changes_enable`. Please set this dictionary by adding such
+lines to your user config file::

cosmetic_changes_disable['wikipedia'] = ('de', 'en', 'fr')

diff --git a/pywikibot/data/mysql.py b/pywikibot/data/mysql.py
index f5ef7d9..6e7a83c 100644
--- a/pywikibot/data/mysql.py
+++ b/pywikibot/data/mysql.py
@@ -76,7 +76,7 @@
if None, config.verbose_output will be used.
:return: generator which yield tuples
"""
- # These are specified in config.py or user-config.py
+ # These are specified in config.py or your user config file
if verbose is None:
verbose = config.verbose_output

diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index 7a16571..941ef96 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -30,7 +30,7 @@

def _command(self, file_name: str, text: str,
jump_index: Optional[int] = None) -> List[str]:
- """Return editor selected in user-config.py."""
+ """Return editor selected in user config file (user-config.py)."""
if jump_index:
# Some editors make it possible to mark occurrences of substrings,
# or to jump to the line of the first occurrence.
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 835f25e..5f03b42 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -68,7 +68,7 @@

Error: Base class, all exceptions should the subclass of this class.

- - NoUsernameError: Username is not in user-config.py, or it is invalid.
+ - NoUsernameError: Username is not in user config file, or it is invalid.
- AutoblockUserError: requested action on a virtual autoblock user not valid
- TranslationError: no language translation found
- UserRightsError: insufficient rights for requested action
@@ -343,7 +343,7 @@

class NoUsernameError(Error):

- """Username is not in user-config.py."""
+ """Username is not in user config file (user-config.py)."""


class NoPageError(PageRelatedError):
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 2bbbebd..0cac48c 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -101,11 +101,10 @@
raise NoUsernameError(
'ERROR: '
'username for {site.family.name}:{site.code} is undefined.'
- '\nIf you have a username for that site, '
- 'please add a line to user-config.py as follows:\n'
+ '\nIf you have a username for that site, please add a '
+ 'line to user config file (user_config.py) as follows:\n'
"usernames['{site.family.name}']['{site.code}'] = "
- "'myUsername'"
- .format(site=site))
+ "'myUsername'".format(site=site))
self.password = password
self.login_name = self.username = user
if getattr(config, 'password_file', ''):
diff --git a/pywikibot/page/_pages.py b/pywikibot/page/_pages.py
index cc11304..d4759a8 100644
--- a/pywikibot/page/_pages.py
+++ b/pywikibot/page/_pages.py
@@ -1080,7 +1080,7 @@

The framework enforces this restriction by default. It is possible
to override this by setting ignore_bot_templates=True in
- user-config.py, or using page.put(force=True).
+ user cnfig file (user-config.py), or using page.put(force=True).
"""
if not hasattr(self, '_bot_may_edit'):
self._bot_may_edit = self._check_bot_may_edit()
diff --git a/pywikibot/scripts/__init__.py b/pywikibot/scripts/__init__.py
index a75744f..f5c6223 100644
--- a/pywikibot/scripts/__init__.py
+++ b/pywikibot/scripts/__init__.py
@@ -14,7 +14,7 @@


def _import_with_no_user_config(*import_args):
- """Return ``__import__(*import_args)`` without loading user-config.py.
+ """Return ``__import__(*import_args)`` without loading user config.

.. versionadded:: 3.0
.. versionchanged:: 7.0
diff --git a/pywikibot/scripts/generate_user_files.py b/pywikibot/scripts/generate_user_files.py
index 018440b..443aa82 100755
--- a/pywikibot/scripts/generate_user_files.py
+++ b/pywikibot/scripts/generate_user_files.py
@@ -1,5 +1,5 @@
#!/usr/bin/python3
-"""Script to create user-config.py.
+"""Script to create user-config.py. Other file names are not supported.

.. versionchanged:: 7.0
moved to pywikibot.scripts folder
diff --git a/pywikibot/scripts/login.py b/pywikibot/scripts/login.py
index e45273b..b44ec28 100755
--- a/pywikibot/scripts/login.py
+++ b/pywikibot/scripts/login.py
@@ -14,7 +14,7 @@
-site:FF:LL Log in to the LL language of the FF family

-all Try to log in on all sites where a username is defined in
- user-config.py.
+ user config file (user-config.py).

-logout Log out of the current site. Combine with -all to log out of
all sites, or with -family and -lang to log out of a specific
@@ -22,8 +22,8 @@

-oauth Generate OAuth authentication information.

- .. note:: Need to copy OAuth tokens to your user-config.py
- manually. -logout is not compatible with -oauth.
+ .. note:: Need to copy OAuth tokens to your user config
+ file manually. -logout is not compatible with -oauth.

-autocreate Auto-create an account using unified login when necessary.

@@ -81,7 +81,7 @@
pywikibot.output('Logged in on {site} as {username}'
'via OAuth consumer {consumer}\n'
'NOTE: To use OAuth, you need to copy the '
- 'following line to your user-config.py:\n'
+ 'following line to your user config file:\n'
'authenticate[{hostname!r}] = {oauth_token}'
.format(site=site,
username=site.username(),
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index de85f4a..ef174a5 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -333,7 +333,7 @@
:param autocreate: if true, allow auto-creation of the account
using unified login
:param user: bot user name. Overrides the username set by
- BaseSite initializer parameter or user-config.py setting
+ BaseSite initializer parameter or user config setting

:raises pywikibot.exceptions.NoUsernameError: Username is not
recognised by the site.
@@ -382,7 +382,7 @@
.format(self))
elif self.username() is None:
error_msg = ('No username has been defined in your '
- 'user-config.py: you have to add in this '
+ 'user config file: you have to add in this '
'file the following line:\n'
'usernames[{family!r}][{lang!r}]= {username!r}'
.format(family=self.family,
diff --git a/pywikibot/site_detect.py b/pywikibot/site_detect.py
index 0c20305..5846e38 100644
--- a/pywikibot/site_detect.py
+++ b/pywikibot/site_detect.py
@@ -144,7 +144,7 @@
self.private_wiki = ('error' in info
and info['error']['code'] == 'readapidenied')
if self.private_wiki:
- # user-config.py is not loaded because PYWIKIBOT_NO_USER_CONFIG
+ # user config is not loaded because PYWIKIBOT_NO_USER_CONFIG
# is set to '2' by generate_family_file.py.
# Prepare a temporary config for login.
username = pywikibot.input(
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index 743f38e..16e38e7 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -68,7 +68,7 @@
would be overwritten or another mistake would be risked. Set it to
an array of warning codes to selectively ignore specific warnings.
:param target_site: Set the site to upload to. If target site is not
- given it's taken from user-config.py.
+ given it's taken from user config file (user_config.py).
:type target_site: object
:param aborts: List of the warning types to abort upload on. Set to
True to abort on any warning.
diff --git a/scripts/__init__.py b/scripts/__init__.py
index c482795..1af0568 100644
--- a/scripts/__init__.py
+++ b/scripts/__init__.py
@@ -17,8 +17,8 @@

- check for framework and script depedencies and show a warning if a
package is missing or outdated or if the Python release does not fit
-- check whether user-config.py config file is available and ask to
- create it by starting the generate_user_files.py script
+- check whether user config file (user-config.py) is available and ask
+ to create it by starting the generate_user_files.py script
- enable global options even if a script does not support them
- start private scripts located in userscripts sub-folder
- find a script even if given script name does not match a filename e.g.
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index f312393..d988b18 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -317,7 +317,7 @@

without_interwiki: save file with local articles without interwikis

-All these options can be changed through the user-config.py configuration file.
+All these options can be changed through the user configuration file.

If interwiki.py is terminated before it is finished, it will write a dump file
to the interwiki-dumps subdirectory. The program will read it if invoked with
diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py
index 18735fa..bbfaf20 100755
--- a/scripts/replicate_wiki.py
+++ b/scripts/replicate_wiki.py
@@ -14,8 +14,8 @@
pages have to be changed if -r is not present, and will only actually write
pages if -r /is/ present.

-You can add replicate_replace to your user-config.py, which has the following
-format:
+You can add replicate_replace to your user config file (user-config.py),
+which has the following format:

replicate_replace = {
'wikipedia:li': {'Hoofdpagina': 'Veurblaad'}
diff --git a/scripts/watchlist.py b/scripts/watchlist.py
index fefb011..bd72dc8 100755
--- a/scripts/watchlist.py
+++ b/scripts/watchlist.py
@@ -16,8 +16,8 @@
account the bot has access to
-count:all Count only the total number of pages on all wikis watchlists
that the bot is connected to.
--new Load watchlists for all wikis where accounts is setting in
- user-config.py
+-new Load watchlists for all wikis where accounts is set in user
+ config file

.. versionchanged:: 7.7
watchlist is retrieved in parallel tasks.
@@ -108,9 +108,9 @@


def refresh_new() -> None:
- """Load watchlists of all wikis for accounts set in user-config.py."""
- pywikibot.output(
- 'Downloading all watchlists for your accounts in user-config.py')
+ """Load watchlists of all wikis for accounts set in user config."""
+ pywikibot.output('Downloading all watchlists for your accounts in {}'
+ .format(config.user_config_file))
count_watchlist_all(quiet=True)


diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index 0662820..265e4ee 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -21,11 +21,11 @@
After running the bot and waiting for at least one week, you can re-check those
pages where dead links were found, using the -repeat parameter.

-In addition to the logging step, it is possible to automatically report dead
-links to the talk page of the article where the link was found. To use this
-feature, set report_dead_links_on_talk = True in your user-config.py, or
-specify "-talk" on the command line. Adding "-notalk" switches this off
-irrespective of the configuration variable.
+In addition to the logging step, it is possible to automatically report
+dead links to the talk page of the article where the link was found. To
+use this feature, set report_dead_links_on_talk = True in your user
+config file, or specify "-talk" on the command line. Adding "-notalk"
+switches this off irrespective of the configuration variable.

When a link is found alive, it will be removed from the .dat file.

diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py
index b1afeff..69f335f 100755
--- a/tests/pwb_tests.py
+++ b/tests/pwb_tests.py
@@ -25,11 +25,10 @@

class TestPwb(PwbTestCase):

- """
- Test pwb.py functionality.
+ """Test pwb.py functionality.

- This is registered as a Site test because it will not run
- without a user-config.py
+ This is registered as a Site test because it will not run without a
+ user config file.
"""

# site must be explicitly set for pwb tests. This test does not require
diff --git a/user-config.py.sample b/user-config.py.sample
index cf80b2c..ef3d526 100644
--- a/user-config.py.sample
+++ b/user-config.py.sample
@@ -1,4 +1,4 @@
-# This is a sample file. You should use generate_user_files script
+# This is a sample file. You can use generate_user_files script
# to create your user-config.py file:
# pwb generate_user_files


To view, visit change 830872. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I7c83d4000fea160b602261f740936689aa224aca
Gerrit-Change-Number: 830872
Gerrit-PatchSet: 9
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Masti <mastigm@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged