jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1108156?usp=email )
Change subject: cleanup: remove old deprecation variables
......................................................................
cleanup: remove old deprecation variables
- remove deprecated variables which where added in Pywikibot 6.0 and
before. A deprecation warning was already thrown. There is a generic
warning if they are still used.
- remove _future_variables and add content to _deprecated_variables.
_future_variables were added with 4.0 for imports from __future__ but
they are obsolete with sundown of Python 2. Add them to deprecation
warning.
- fix deprecation warning
Change-Id: Ib0df1ae4ebcd3576afd245eec754462bd4c27f8a
---
M pywikibot/config.py
1 file changed, 8 insertions(+), 15 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config.py b/pywikibot/config.py
index cabc17c..55e1916 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -102,21 +102,14 @@
# exported to other modules.
_private_values = {'authenticate', 'db_password'}
+# _deprecated_variables contains deprecated config variables which are
+# no longer used. The values of this dict is the Pywikibot version of
+# the deprecation but unused.
_deprecated_variables = {
- 'available_ssl_project', 'copyright_check_in_source_google',
- 'copyright_check_in_source_msn', 'copyright_check_in_source_section_names',
- 'copyright_check_in_source_yahoo', 'copyright_connection_tries',
- 'copyright_economize_query', 'copyright_exceeded_in_queries',
- 'copyright_exceeded_in_queries_sleep_hours', 'copyright_google',
- 'copyright_max_query_for_page', 'copyright_msn', 'copyright_show_date',
- 'copyright_show_length', 'copyright_skip_query', 'copyright_yahoo',
- 'db_hostname', 'deIndentTables', 'fake_user_agent', 'flickr',
- 'interwiki_contents_on_disk', 'line_separator', 'LS', 'msn_appid',
- 'panoramio', 'persistent_http', 'proxy', 'special_page_limit',
- 'splitLongParagraphs', 'sysopnames', 'use_mwparserfromhell',
- 'use_SSL_onlogin', 'use_SSL_always', 'yahoo_appid',
+ 'absolute_import': '10.0.0 ',
+ 'division': '10.0.0',
+ 'unicode_literals': '10.0.0',
}
-_future_variables = {'absolute_import', 'division', 'unicode_literals'}
# ############# ACCOUNT SETTINGS ##############
@@ -998,7 +991,7 @@
DEPRECATED_VARIABLE = (
- f'"{{}}" present in our {user_config_file} is no longer a supported'
+ f'"{{}}" present in your {user_config_file} is no longer a supported'
' configuration variable and should be removed. Please inform the'
' maintainers if you depend on it.'
)
@@ -1026,7 +1019,7 @@
if name in _deprecated_variables:
warn('\n' + fill(DEPRECATED_VARIABLE.format(name)),
_ConfigurationDeprecationWarning)
- elif name not in _future_variables:
+ else:
warn('\n' + fill(f'Configuration variable "{name}" is defined '
f'in your {user_config_file} but unknown. It'
' can be a misspelled one or a variable that'
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1108156?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: Ib0df1ae4ebcd3576afd245eec754462bd4c27f8a
Gerrit-Change-Number: 1108156
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1107961?usp=email )
Change subject: [IMPR] Simplify colorTagR
......................................................................
[IMPR] Simplify colorTagR
only include the outer colorTagR regex group and hide the separate
groups fg_col and bg_col which were never used.
Use batched instead of text_parts slice to process a line.
Change-Id: Ie2bfec424af6360278cb41d7512638d5dd099caf
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 8 insertions(+), 11 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index c3afee5..c3cc545 100644
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -15,7 +15,7 @@
import pywikibot
from pywikibot import config
-from pywikibot.backports import Iterable, Sequence, removeprefix
+from pywikibot.backports import Iterable, Sequence, batched, removeprefix
from pywikibot.bot_choice import (
ChoiceException,
Option,
@@ -53,7 +53,7 @@
]
colorTagR = re.compile(
- '<<((:?{0});?(:?{0})?)>>'.format('|'.join([*colors, 'previous'])))
+ '<<((?:{0})(?:;(?:{0}))?)>>'.format('|'.join([*colors, 'previous'])))
class UI(ABUIC):
@@ -198,16 +198,13 @@
# Add default before the last linefeed
if text.endswith('\n'):
text_parts[-1] = re.sub(r'\r?\n\Z', '', text_parts[-1])
- text_parts.extend(('default', None, None,
- '\n', 'default', None, None))
- else:
- text_parts.append('default')
+ text_parts.extend(('default', '\n'))
- # match.split() includes every regex group; for each matched color
- # fg_col:b_col, fg_col and bg_col are added to the resulting list.
- len_text_parts = len(text_parts[::4])
- for index, (txt, next_color) in enumerate(zip(text_parts[::4],
- text_parts[1::4])):
+ text_parts.append('default')
+
+ len_text_parts = len(text_parts) // 2
+ for index, (txt, next_color) in enumerate(batched(text_parts, 2,
+ strict=True)):
current_color = color_stack[-1]
if next_color == 'previous':
if len(color_stack) > 1: # keep the last element in the stack
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1107961?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: Ie2bfec424af6360278cb41d7512638d5dd099caf
Gerrit-Change-Number: 1107961
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1107954?usp=email )
Change subject: [FIX] Fix <<default>> color tag
......................................................................
[FIX] Fix <<default>> color tag
<<default>> color tag must be appended before the last linefeed
Also update ui_tests and usage
Bug: T382884
Change-Id: I0ec3b7c3046394af39ef25bd09517590f53a90ea
---
M pywikibot/__init__.py
M pywikibot/userinterfaces/terminal_interface_base.py
M tests/ui_tests.py
3 files changed, 15 insertions(+), 6 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 207eff1..2f6c4c0 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1,6 +1,6 @@
"""The initialization file for the Pywikibot framework."""
#
-# (C) Pywikibot team, 2008-2024
+# (C) Pywikibot team, 2008-2025
#
# Distributed under the terms of the MIT license.
#
@@ -338,7 +338,7 @@
num, sec = remaining()
if num > 0 and sec.total_seconds() > _config.noisysleep:
output(f'<<lightblue>>Waiting for {num} pages to be put. '
- f'Estimated time remaining: {sec}<<default>>')
+ f'Estimated time remaining: {sec}')
exit_queue = None
if _putthread is not threading.current_thread():
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index e95a793..c3afee5 100644
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -1,6 +1,6 @@
"""Base for terminal user interfaces."""
#
-# (C) Pywikibot team, 2003-2024
+# (C) Pywikibot team, 2003-2025
#
# Distributed under the terms of the MIT license.
#
@@ -194,7 +194,15 @@
# Therefore we need this stack.
color_stack = ['default']
text_parts = colorTagR.split(text)
- text_parts.append('default')
+
+ # Add default before the last linefeed
+ if text.endswith('\n'):
+ text_parts[-1] = re.sub(r'\r?\n\Z', '', text_parts[-1])
+ text_parts.extend(('default', None, None,
+ '\n', 'default', None, None))
+ else:
+ text_parts.append('default')
+
# match.split() includes every regex group; for each matched color
# fg_col:b_col, fg_col and bg_col are added to the resulting list.
len_text_parts = len(text_parts[::4])
@@ -210,6 +218,7 @@
if current_color != next_color:
colored_line = True
+
if colored_line and not colorized:
if '\n' in txt: # Normal end of line
txt = txt.replace('\n', ' ***\n', 1)
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index dab9f02..3a15ca5 100755
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Tests for the user interface."""
#
-# (C) Pywikibot team, 2008-2022
+# (C) Pywikibot team, 2008-2025
#
# Distributed under the terms of the MIT license.
#
@@ -449,7 +449,7 @@
def test_one_color_newline(self):
"""Test with trailing new line and one color."""
- self._colors = (('red', 6), ('default', 11))
+ self._colors = (('red', 6), ('default', 10))
with redirect_stdout(self.redirect) as f:
self.ui_obj._print('Hello <<red>>world you!\n',
self.ui_obj.stdout)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1107954?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: I0ec3b7c3046394af39ef25bd09517590f53a90ea
Gerrit-Change-Number: 1107954
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot