jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1009778?usp=email )
Change subject: [IMPR] use global -code instead of -lang to determine a site
......................................................................
[IMPR] use global -code instead of -lang to determine a site
site.code is the identifying code of a site presumed to be equal to the
wiki prefix whereas site language is the ISO language code for a site.
e.g. 'als' is a site code whereas its site language is 'gsw'
'meta' is a site code whereas its language is 'en'
The global option should follow this difference.
The old -lang option is kept for backward compatibility.
Patch detached from I145c0dc283ff597a697752aec901c1a14e6b1416
Change-Id: Ieb78b3a99505b28f99ced4ba912c3b11431063de
---
M .github/workflows/login_tests-ci.yml
M .github/workflows/oauth_tests-ci.yml
M .github/workflows/pywikibot-ci.yml
M HISTORY.rst
M pywikibot/bot.py
M pywikibot/page/_basepage.py
M pywikibot/scripts/generate_user_files.py
M pywikibot/scripts/login.py
M pywikibot/scripts/wrapper.py
M scripts/coordinate_import.py
M scripts/harvest_template.py
M scripts/replicate_wiki.py
M scripts/transferbot.py
M tests/README.rst
M tox.ini
15 files changed, 41 insertions(+), 39 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/.github/workflows/login_tests-ci.yml
b/.github/workflows/login_tests-ci.yml
index 035c9a7..cf2b878 100644
--- a/.github/workflows/login_tests-ci.yml
+++ b/.github/workflows/login_tests-ci.yml
@@ -102,7 +102,7 @@
if [ ${{matrix.site}} != false ]; then
python -Werror::UserWarning -m pwb generate_user_files
-site:${{matrix.site}} -user:${{ env.PYWIKIBOT_USERNAME }} -v -debug;
else
- python -Werror::UserWarning -m pwb generate_user_files
-family:${{matrix.family}} -lang:${{matrix.code}} -user:${{
env.PYWIKIBOT_USERNAME }} -v -debug;
+ python -Werror::UserWarning -m pwb generate_user_files
-family:${{matrix.family}} -code:${{matrix.code}} -user:${{
env.PYWIKIBOT_USERNAME }} -v -debug;
fi
echo "usernames['wikipedia']['en'] = '${{ env.PYWIKIBOT_USERNAME
}}'" >> user-config.py
echo "usernames['wikisource']['zh'] = '${{ env.PYWIKIBOT_USERNAME
}}'" >> user-config.py
diff --git a/.github/workflows/oauth_tests-ci.yml
b/.github/workflows/oauth_tests-ci.yml
index 381ee95..7ba998d 100644
--- a/.github/workflows/oauth_tests-ci.yml
+++ b/.github/workflows/oauth_tests-ci.yml
@@ -79,7 +79,7 @@
python pwb.py generate_family_file
http://${{matrix.code}}.wikipedia.beta.wmcloud.org/ wpbeta y
- name: Generate user files
run: |
- python -Werror::UserWarning -m pwb generate_user_files
-family:${{matrix.family}} -lang:${{matrix.code}} -user:${{
env.PYWIKIBOT_USERNAME }} -v -debug;
+ python -Werror::UserWarning -m pwb generate_user_files
-family:${{matrix.family}} -code:${{matrix.code}} -user:${{
env.PYWIKIBOT_USERNAME }} -v -debug;
echo "usernames['commons']['beta'] = '${{ env.PYWIKIBOT_USERNAME
}}'" >> user-config.py
echo "usernames['meta']['meta'] = '${{ env.PYWIKIBOT_USERNAME }}'"
>> user-config.py
echo "authenticate['${{ matrix.domain }}'] = ('${{
steps.split.outputs._0 }}', '${{ steps.split.outputs._1 }}', '${{
steps.split.outputs._2 }}', '${{ steps.split.outputs._3 }}')" >> user-config.py
diff --git a/.github/workflows/pywikibot-ci.yml
b/.github/workflows/pywikibot-ci.yml
index a0ca8af..342ba01 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -97,7 +97,7 @@
if [ ${{matrix.site}} != false ]; then
python -Werror::UserWarning -m pwb generate_user_files
-site:${{matrix.site}} -user:${{ env.PYWIKIBOT_USERNAME }} -v -debug;
else
- python -Werror::UserWarning -m pwb generate_user_files
-family:${{matrix.family}} -lang:${{matrix.code}} -user:${{
env.PYWIKIBOT_USERNAME }} -v -debug;
+ python -Werror::UserWarning -m pwb generate_user_files
-family:${{matrix.family}} -code:${{matrix.code}} -user:${{
env.PYWIKIBOT_USERNAME }} -v -debug;
fi
echo "usernames['wikipedia']['en'] = '${{ env.PYWIKIBOT_USERNAME
}}'" >> user-config.py
echo "usernames['wikisource']['zh'] = '${{ env.PYWIKIBOT_USERNAME
}}'" >> user-config.py
diff --git a/HISTORY.rst b/HISTORY.rst
index 4736e14..8437e93 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1578,7 +1578,7 @@
* Do not strip all whitespaces from Link.title (:phab:`T197642`)
* Introduce a common BaseDataDict as parent for LanguageDict and AliasesDict
* Replaced PageNotSaved by PageSaveRelatedError (:phab:`T267821`)
-* Add -site option as -family -lang shortcut
+* Add -site option as -family -code shortcut
* Enable APISite.exturlusage() with default parameters (:phab:`T266989`)
* Update tools._unidata._category_cf from Unicode version 13.0.0
* Move TokenWallet to site/_tokenwallet.py file
@@ -1694,7 +1694,7 @@
* Add support for ja.wikivoyage (:phab:`T261450`)
* Only run cosmetic changes on wikitext pages (:phab:`T260489`)
-* Leave a script gracefully for wrong -lang and -family option
(:phab:`T259756`)
+* Leave a script gracefully for wrong -code and -family option
(:phab:`T259756`)
* Change meaning of BasePage.text (:phab:`T260472`)
* site/family methods code2encodings() and code2encoding() has been removed in
favour of encoding()/encodings() methods
* Site.getExpandedString() method was removed in favour of expand_text
@@ -2549,7 +2549,7 @@
- added ISBN support
- added redirect support
* Optionally uses external library for improved isbn validation
-* Automatically generating user files when -user, -family and -lang are
+* Automatically generating user files when -user, -family and -code are
provided to a script
* Page.content_model added
* Page.contributors() and Page.revision_count() added
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 96b2695..0d28d98 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -205,9 +205,8 @@
-config:xyn The user config filename. Default is user-config.py.
--lang:xx Set the language of the wiki you want to work on,
+-code:xx Set the site code 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
@@ -689,7 +688,7 @@
"""Handle global command line arguments and return the rest as a list.
Takes the command line arguments as strings, processes all
- :ref:`global parameters<global options>` such as ``-lang`` or
+ :ref:`global parameters<global options>` such as ``-code`` 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
@@ -725,17 +724,20 @@
script.
.. versionchanged:: 5.2
- *-site* global option was added
+ ``-site`` global option was added
.. versionchanged:: 7.1
- *-cosmetic_changes* and *-cc* may be set directly instead of
+ ``-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.
+ ``-config`` global option was added.
.. versionchanged:: 8.0
Short site value can be given if site code is equal to family
like ``-site:meta``.
.. versionchanged:: 8.1
``-nolog`` option also discards command.log.
+ .. versionchanged:: 11.0
+ ``-lang`` option was replaced by ``-code`` but kept for backward
+ compatibility.
:param args: Command line arguments. If None,
:meth:`pywikibot.argvu<userinterfaces._interface_base.ABUIC.argvu>`
@@ -779,7 +781,7 @@
config.family = config.mylang = value
elif option == '-family':
config.family = value
- elif option == '-lang':
+ elif option in ('-code', '-lang'): # -lang might be deprecated later
config.mylang = value
elif option == '-user':
username = value
diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py
index d6d874e..51f6449 100644
--- a/pywikibot/page/_basepage.py
+++ b/pywikibot/page/_basepage.py
@@ -211,7 +211,7 @@
) -> str:
"""Return the title of this Page, as a string.
- :param underscore: Not used with as_link, If true, replace all
+ :param underscore: Not used with *as_link*, If true, replace all
spaces with underscores.
:param with_ns: If false, omit the namespace prefix. If this
option is False and used together with *as_link* return a
@@ -229,9 +229,9 @@
a ':' before ``Category:`` and ``Image:`` links.
:param as_filename: Not used with *as_link*, If true, replace
any characters that are unsafe in filenames.
- :param insite: Only used if *as_link* is true, A site object
+ :param insite: Only used if *as_link* is true, a site object
where the title is to be shown. Default is the current
- family/lang given by ``-family`` and ``-lang`` or ``-site``
+ family/code given by ``-family`` and ``-code`` or ``-site``
option i.e. config.family and config.mylang.
:param without_brackets: Cannot be used with *as_link*, If true,
remove the last pair of brackets (usually removes
diff --git a/pywikibot/scripts/generate_user_files.py
b/pywikibot/scripts/generate_user_files.py
index 8676088..be8ad99 100755
--- a/pywikibot/scripts/generate_user_files.py
+++ b/pywikibot/scripts/generate_user_files.py
@@ -508,7 +508,7 @@
:param args: Command line arguments
"""
# set the config family and mylang values to an invalid state so that
- # the script can detect that the command line arguments -family & -lang
+ # the script can detect that the command line arguments -family & -code
# or -site were used and handle_args has updated these config values,
# and 'force' mode can be activated below.
config.family, config.mylang = 'wikipedia', None
diff --git a/pywikibot/scripts/login.py b/pywikibot/scripts/login.py
index fe430b9..e8110da 100755
--- a/pywikibot/scripts/login.py
+++ b/pywikibot/scripts/login.py
@@ -13,7 +13,7 @@
-logout Log out of the current site. Combine with ``-all`` to log
out of all sites, or with :ref:`global options` ``-family``,
- ``-lang`` or ``-site`` to log out of a specific site.
+ ``-code`` or ``-site`` to log out of a specific site.
-oauth Generate OAuth authentication information.
diff --git a/pywikibot/scripts/wrapper.py b/pywikibot/scripts/wrapper.py
index f777fa1..5bdcbce 100755
--- a/pywikibot/scripts/wrapper.py
+++ b/pywikibot/scripts/wrapper.py
@@ -29,7 +29,7 @@
Currently, `<pwb options>` are :ref:`global options`. This can be used
for tests to set the default site (see :phab:`T216825`)::
- python pwb.py -lang:de bot_tests -v
+ python pwb.py -code:de bot_tests -v
.. seealso:: :mod:`pwb` entry point
.. versionchanged:: 7.0
diff --git a/scripts/coordinate_import.py b/scripts/coordinate_import.py
index aaba65d..01225e7 100755
--- a/scripts/coordinate_import.py
+++ b/scripts/coordinate_import.py
@@ -16,7 +16,7 @@
You can use any typical pagegenerator to provide with a list of pages:
- python pwb.py coordinate_import -lang:it -family:wikipedia -namespace:0 \
+ python pwb.py coordinate_import -site:wikipedia:it -namespace:0 \
-transcludes:Infobox_stazione_ferroviaria
You can also run over a set of items on the repo without coordinates and
@@ -42,7 +42,7 @@
¶ms;
"""
#
-# (C) Pywikibot team, 2013-2024
+# (C) Pywikibot team, 2013-2026
#
# Distributed under the terms of MIT license.
#
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index 9ac823e..3e8ac9b 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -52,27 +52,27 @@
parameter of "Infobox person" on English Wikipedia as Wikidata property
"P18" (image):
- python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
+ python pwb.py harvest_template -site:wikipedia:en -namespace:0 \
-template:"Infobox person" image P18
The following command will behave the same as the previous example and
also try to import [[links]] from "birth_place" parameter of the same
template as Wikidata property "P19" (place of birth):
- python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
+ python pwb.py harvest_template -site:wikipedia:en -namespace:0 \
-template:"Infobox person" image P18 birth_place P19
The following command will import both "birth_place" and "death_place"
params with -islink modifier, ie. the bot will try to import values,
even if it doesn't find a [[link]]:
- python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
+ python pwb.py harvest_template -site:wikipedia:en -namespace:0 \
-template:"Infobox person" -islink birth_place P19 death_place P20
The following command will do the same but only "birth_place" can be
imported without a link:
- python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
+ python pwb.py harvest_template -site:wikipedia:en -namespace:0 \
-template:"Infobox person" birth_place P19 -islink death_place P20
The following command will import an occupation from "occupation"
@@ -80,7 +80,7 @@
"P106" (occupation). The page won't be skipped if the item already has
that property but there is not the new value:
- python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
+ python pwb.py harvest_template -site:wikipedia:en -namespace:0 \
-template:"Infobox person" occupation P106 -exists:p
The following command will import band members from the "current_members"
@@ -88,7 +88,7 @@
property "P527" (has part). This will only extract multiple band members
if each is linked, and will not add duplicate claims for the same member:
- python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
+ python pwb.py harvest_template -site:wikipedia:en -namespace:0 \
-template:"Infobox musical artist" current_members P527 -exists:p -multi
The following command will import the category's main topic from the
@@ -98,7 +98,7 @@
property "P910" (topic's main category) unless a claim of that property
is already there:
- python pwb.py harvest_template -lang:en -family:wikipedia -namespace:14 \
+ python pwb.py harvest_template -site:wikipedia:en -namespace:14 \
-template:"Cat main" 1 P301 -inverse:P910 -islink
@@ -109,7 +109,7 @@
the -inverse option.
"""
#
-# (C) Pywikibot team, 2013-2025
+# (C) Pywikibot team, 2013-2026
#
# Distributed under the terms of MIT license.
#
diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py
index d77ee59..9762e50 100755
--- a/scripts/replicate_wiki.py
+++ b/scripts/replicate_wiki.py
@@ -9,7 +9,7 @@
or::
- python pwb.py replicate_wiki [-r] -ns 10 -family:wikipedia -lang:nl li fy
+ python pwb.py replicate_wiki [-r] -ns 10 -family:wikipedia -code:nl li fy
to copy all templates from nlwiki to liwiki and fywiki. It will show
which pages have to be changed if -r is not present, and will only
@@ -33,7 +33,7 @@
-r, --replace actually replace pages (without this option
you will only get an overview page)
--o, --original original wiki (you may use -lang:<code> option
+-o, --original original wiki (you may use -code:<code> option
instead)
-ns, --namespace specify namespace
@@ -42,7 +42,7 @@
destination_wiki destination wiki(s)
"""
#
-# (C) Pywikibot team, 2012-2024
+# (C) Pywikibot team, 2012-2026
#
# Distributed under the terms of the MIT license.
#
diff --git a/scripts/transferbot.py b/scripts/transferbot.py
index 252bde8..c96f576 100755
--- a/scripts/transferbot.py
+++ b/scripts/transferbot.py
@@ -29,22 +29,22 @@
Transfer all pages in category "Query service" from the English Wikipedia to
the Arabic Wiktionary, adding "Wiktionary:Import enwp/" as prefix:
- python pwb.py transferbot -family:wikipedia -lang:en -cat:"Query service" \
+ python pwb.py transferbot -site:wikipedia:en -cat:"Query service" \
-tofamily:wiktionary -tolang:ar -prefix:"Wiktionary:Import enwp/"
Copy the template "Query service" from the English Wikipedia to the
Arabic Wiktionary:
- python pwb.py transferbot -family:wikipedia -lang:en -tofamily:wiktionary \
+ python pwb.py transferbot -site:wikipedia:en -tofamily:wiktionary \
-tolang:ar -page:"Template:Query service"
Copy 10 wanted templates of German Wikipedia from English Wikipedia to German:
- python pwb.py transferbot -family:wikipedia -lang:en -tolang:de \
+ python pwb.py transferbot -site:wikipedia:en -tolang:de \
-wantedtemplates:10 -target
"""
#
-# (C) Pywikibot team, 2014-2024
+# (C) Pywikibot team, 2014-2026
#
# Distributed under the terms of the MIT license.
#
diff --git a/tests/README.rst b/tests/README.rst
index b8a61fc..b58d311 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -45,7 +45,7 @@
------------------
Individual test components can be run using unittest, pytest or pwb.
-With -lang and -family or -site options pwb can be used to specify a site.
+With -code and -family or -site options pwb can be used to specify a site.
**unittest**
@@ -69,7 +69,7 @@
python pwb.py tests/api_tests -v
python pwb.py tests/site_tests -v
python pwb.py tests/api_tests -v TestParamInfo.test_init
- python pwb.py -lang:de -family:wikipedia tests/page_tests -v TestPageObject
+ python pwb.py -site:wikipedia:de tests/page_tests -v TestPageObject
**env**
diff --git a/tox.ini b/tox.ini
index 8231b1c..5a35511 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,7 @@
[params]
# Note: tox 4 does not support multiple lines when doing parameters
# substitution.
-generate_user_files = -W error::UserWarning -m pwb generate_user_files
-family:wikipedia -lang:test -v
+generate_user_files = -W error::UserWarning -m pwb generate_user_files
-site:wikipedia:test -v
# ignores: gui.py (needs tkinter), memento.py (has too many timeouts)
DOCTEST_IGNORES = --ignore-glob=*gui.py --ignore-glob=*memento.py
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1009778?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ieb78b3a99505b28f99ced4ba912c3b11431063de
Gerrit-Change-Number: 1009778
Gerrit-PatchSet: 7
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]