jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1019575?usp=email )

Change subject: [IMPR] add a new -usernames option to scripts.version.py
......................................................................

[IMPR] add a new -usernames option to scripts.version.py

only show usernames for registered families if -usernames option is given.

Change-Id: Iaf6fda90b784fc6edd0cbd56e7b03196b2f1874f
---
M .github/workflows/doctest.yml
M .github/workflows/login_tests-ci.yml
M .github/workflows/oauth_tests-ci.yml
M .github/workflows/pywikibot-ci.yml
M .github/workflows/sysop_write_tests-ci.yml
M pywikibot/scripts/version.py
6 files changed, 22 insertions(+), 7 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/.github/workflows/doctest.yml b/.github/workflows/doctest.yml
index fae76f3..fd33f88 100644
--- a/.github/workflows/doctest.yml
+++ b/.github/workflows/doctest.yml
@@ -67,7 +67,7 @@
     - name: doctest with pytest
       timeout-minutes: 5
       run: |
-        python pwb.py version
+        python pwb.py version -usernames
         pytest --version
         coverage run -m pytest pywikibot --doctest-modules 
--ignore-glob="*gui.py" --ignore-glob="*memento.py"

diff --git a/.github/workflows/login_tests-ci.yml 
b/.github/workflows/login_tests-ci.yml
index 5cc02a2..5554e7d 100644
--- a/.github/workflows/login_tests-ci.yml
+++ b/.github/workflows/login_tests-ci.yml
@@ -110,7 +110,7 @@
     - name: Test with unittest
       timeout-minutes: 2
       run: |
-        python pwb.py version
+        python pwb.py version -usernames
         coverage run -m unittest -vv tests/site_login_logout_tests.py

     - name: Show coverage statistics
diff --git a/.github/workflows/oauth_tests-ci.yml 
b/.github/workflows/oauth_tests-ci.yml
index f93c6dd..eb8a221 100644
--- a/.github/workflows/oauth_tests-ci.yml
+++ b/.github/workflows/oauth_tests-ci.yml
@@ -101,7 +101,7 @@
       env:
         PYWIKIBOT_TEST_OAUTH: ${{ secrets[format('{0}', 
steps.token.outputs.uppercase)] }}
       run: |
-        python pwb.py version
+        python pwb.py version -usernames
         coverage run -m unittest -vv tests/oauth_tests.py

     - name: Show coverage statistics
diff --git a/.github/workflows/pywikibot-ci.yml 
b/.github/workflows/pywikibot-ci.yml
index c57535b..1da1d35 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -124,7 +124,7 @@
           ${{ (matrix.site == 'wikisource:zh' || matrix.test_no_rc) && 1 || 0 
}}
         PYWIKIBOT_TEST_PROD_ONLY: ${{ matrix.test_prod_only && 1 || 0 }}
       run: |
-        python pwb.py version
+        python pwb.py version -usernames
         if [ ${{matrix.site || 0}} != 'wikipedia:test' ]; then
           coverage run -m unittest discover -vv -p \"*_tests.py\";
         else
diff --git a/.github/workflows/sysop_write_tests-ci.yml 
b/.github/workflows/sysop_write_tests-ci.yml
index a2bde6f..1986705 100644
--- a/.github/workflows/sysop_write_tests-ci.yml
+++ b/.github/workflows/sysop_write_tests-ci.yml
@@ -80,7 +80,7 @@
         PYWIKIBOT_TEST_OAUTH: ${{ secrets[format('{0}', 
steps.token.outputs.uppercase)] }}
         PYWIKIBOT_TEST_WRITE: ${{ matrix.domain == 'test.wikipedia.org' && 1 
|| 0}}
       run: |
-        python pwb.py version
+        python pwb.py version -usernames
         pytest -s -r A -a "rights or write" --cov=.;

     - name: Show coverage statistics
diff --git a/pywikibot/scripts/version.py b/pywikibot/scripts/version.py
index 1178caf..e18b658 100755
--- a/pywikibot/scripts/version.py
+++ b/pywikibot/scripts/version.py
@@ -1,8 +1,14 @@
 #!/usr/bin/env python3
 """Script to determine the Pywikibot version (tag, revision and date).

+The following option is supported:
+
+-usernames  print usernames for each registered family
+
 .. versionchanged:: 7.0
    version script was moved to the framework scripts folder
+.. versionadded:: 9.1
+   the *-usernames* option.
 """
 #
 # (C) Pywikibot team, 2007-2024
@@ -51,7 +57,11 @@


 def main(*args: str) -> None:
-    """Print pywikibot version and important settings."""
+    """Print pywikibot version and important settings.
+
+    .. versionchanged:: 9.1
+       usernames are printed with ``-usernames`` option only.
+    """
     pywikibot.info('Pywikibot: ' + getversion())
     pywikibot.info('Release version: ' + pywikibot.__version__)
     pywikibot.info('packaging version: ' + packaging.__version__)
@@ -90,7 +100,12 @@
                             os.environ.get(environ_name, 'Not set') or "''"))

     pywikibot.info('Config base dir: ' + pywikibot.config.base_dir)
-    for family, usernames in pywikibot.config.usernames.items():
+
+    if '-usernames' in sys.argv:
+        usernames_items = pywikibot.config.usernames.items()
+    else:
+        usernames_items = {}
+    for family, usernames in usernames_items:
         if not usernames:
             continue
         pywikibot.info(f"Usernames for family '{family}':")

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1019575?usp=email
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: Iaf6fda90b784fc6edd0cbd56e7b03196b2f1874f
Gerrit-Change-Number: 1019575
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to