jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/696935 )
Change subject: [bugfix] Enable replacements with bool(replacements) is False to be imported
......................................................................
[bugfix] Enable replacements with bool(replacements) is False to be imported
If a replacement is given with _add_deprecated_attr method and its
boolean result is false it cannot be imported and an ImportError occurs:
ImportError: cannot import name '<replacement>' from '<module>'.
Therefore check whether a replacement was given explicitly.
Change-Id: I1158e83c8a40857766d43158e636412701ae6b74
---
M pywikibot/tools/__init__.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index cfa3859..877d447 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1886,7 +1886,7 @@
warn(warning_message.format(self._module.__name__, attr, name),
FutureWarning if future else DeprecationWarning, 2)
- if repl:
+ if repl is not None:
return repl
if '.' in name:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/696935
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: I1158e83c8a40857766d43158e636412701ae6b74
Gerrit-Change-Number: 696935
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/696531 )
Change subject: [doc] Update documentation
......................................................................
[doc] Update documentation
* Use Better English
Change-Id: I8a9275b8752e1dc08dadaee912b1f0c7b657f284
---
M pywikibot/cosmetic_changes.py
1 file changed, 6 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index c9c0ee1..9d7e684 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -775,8 +775,8 @@
== Section title ==
:NOTE: This space is recommended in the syntax help on the
- English and German Wikipedia. It is not wanted on Lojban and
- English Wiktionary (T168399, T169064) and it might be that
+ English and German Wikipedias. It is not wanted on Lojban and
+ English Wiktionaries (T168399, T169064) and it might be that
it is not wanted on other wikis. If there are any complaints,
please file a bug report.
"""
@@ -793,7 +793,7 @@
Add a space between the * or # and the text.
:NOTE: This space is recommended in the syntax help on the
- English, German, and French Wikipedia. It might be that it
+ English, German and French Wikipedias. It might be that it
is not wanted on other wikis. If there are any complaints,
please file a bug report.
"""
@@ -1028,10 +1028,10 @@
def commonsfiledesc(self, text):
"""
- Clean up file descriptions on the Wikimedia Commons.
+ Clean up file descriptions on Wikimedia Commons.
- It is working according to [1] and works only on pages in the file
- namespace on the Wikimedia Commons.
+ It works according to [1] and works only on pages in the file
+ namespace on Wikimedia Commons.
[1]:
https://commons.wikimedia.org/wiki/Commons:Tools/pywiki_file_description_cl…
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/696531
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: I8a9275b8752e1dc08dadaee912b1f0c7b657f284
Gerrit-Change-Number: 696531
Gerrit-PatchSet: 5
Gerrit-Owner: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/696497 )
Change subject: [bugfix] postpone hte cached output implementation
......................................................................
[bugfix] postpone hte cached output implementation
Bug: T282962
Change-Id: I0dc8cee5512840b559c76458c02533d598a93c24
---
M ROADMAP.rst
M pywikibot/userinterfaces/terminal_interface_base.py
M tests/i18n_tests.py
3 files changed, 61 insertions(+), 93 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index eb79753..c39575b 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -5,7 +5,6 @@
-------------------------
* Fix iterating of SizedKeyCollection (T282865)
-* The cached output functionality from compat relase was re-implemented (T151727, T73646, T74942, T132135, T144698, T196039, T280466)
* An abstract base user interface module was added
* APISite method pagelanglinks() may skip links with empty titles (T223157)
* Fix Page.getDeletedRevision() method which always returned an empty list
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index 4adcac6..1b12f26 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -13,7 +13,7 @@
import pywikibot
from pywikibot import config
-from pywikibot.backports import Sequence, SimpleQueue
+from pywikibot.backports import Sequence
from pywikibot.bot_choice import (
ChoiceException,
Option,
@@ -22,7 +22,7 @@
StandardOption,
)
from pywikibot.logging import INFO, INPUT, STDOUT, VERBOSE, WARNING
-from pywikibot.tools import deprecated_args, RLock
+from pywikibot.tools import deprecated_args
from pywikibot.userinterfaces import transliteration
from pywikibot.userinterfaces._interface_base import ABUIC
@@ -77,9 +77,6 @@
self.encoding = config.console_encoding
self.transliteration_target = config.transliteration_target
- self.cache = SimpleQueue()
- self.lock = RLock()
-
def init_handlers(self, root_logger, default_stream='stderr'):
"""Initialize the handlers for user output.
@@ -188,38 +185,12 @@
self.encounter_color(color_stack[-1], target_stream)
def output(self, text, targetStream=None):
- """Forward text to cache and flush if output is not locked.
-
- All input methods locks the output to a stream but collect them
- in cache. They will be printed with next unlocked output call or
- at termination time.
- """
- self.cache_output(text, targetStream=targetStream)
- if not self.lock.locked():
- self.flush()
-
- def flush(self):
- """Output cached text."""
- while not self.cache.empty():
- args, kwargs = self.cache.get_nowait()
- self.stream_output(*args, **kwargs)
-
- def cache_output(self, *args, **kwargs):
- """Put text to cache.
-
- *New in version 6.2*
- """
- self.cache.put_nowait((args, kwargs))
-
- def stream_output(self, text, targetStream=None):
"""
Output text to a stream.
If a character can't be displayed in the encoding used by the user's
terminal, it will be replaced with a question mark or by a
transliteration.
-
- *New in version 6.2*
"""
if config.transliterate:
# Encode our unicode string in the encoding used by the user's
@@ -305,26 +276,26 @@
question += end_marker
# lock stream output
- with self.lock:
- if force:
- self.stream_output(question + '\n')
+ # with self.lock: (T282962)
+ if force:
+ self.output(question + '\n')
+ return default
+ # sound the terminal bell to notify the user
+ if config.ring_bell:
+ sys.stdout.write('\07')
+ # TODO: make sure this is logged as well
+ while True:
+ self.output(question + ' ')
+ text = self._input_reraise_cntl_c(password)
+
+ if text is None:
+ continue
+
+ if text:
+ return text
+
+ if default is not None:
return default
- # sound the terminal bell to notify the user
- if config.ring_bell:
- sys.stdout.write('\07')
- # TODO: make sure this is logged as well
- while True:
- self.stream_output(question + ' ')
- text = self._input_reraise_cntl_c(password)
-
- if text is None:
- continue
-
- if text:
- return text
-
- if default is not None:
- return default
def _input_reraise_cntl_c(self, password):
"""Input and decode, and re-raise Control-C."""
@@ -377,7 +348,7 @@
"""Print an OutputOption before or after question."""
if isinstance(option, OutputOption) \
and option.before_question is before_question:
- self.stream_output(option.out + '\n')
+ self.output(option.out + '\n')
if force and default is None:
raise ValueError('With no default option it cannot be forced')
@@ -402,24 +373,24 @@
handled = False
# lock stream output
- with self.lock:
- while not handled:
- for option in options:
- output_option(option, before_question=True)
- output = Option.formatted(question, options, default)
- if force:
- self.stream_output(output + '\n')
- answer = default
- else:
- answer = self.input(output) or default
- # something entered or default is defined
- if answer:
- for index, option in enumerate(options):
- if option.handled(answer):
- answer = option.result(answer)
- output_option(option, before_question=False)
- handled = option.stop
- break
+ # with self.lock: (T282962)
+ while not handled:
+ for option in options:
+ output_option(option, before_question=True)
+ output = Option.formatted(question, options, default)
+ if force:
+ self.output(output + '\n')
+ answer = default
+ else:
+ answer = self.input(output) or default
+ # something entered or default is defined
+ if answer:
+ for index, option in enumerate(options):
+ if option.handled(answer):
+ answer = option.result(answer)
+ output_option(option, before_question=False)
+ handled = option.stop
+ break
if isinstance(answer, ChoiceException):
raise answer
@@ -440,33 +411,31 @@
@return: Return a single Sequence entry.
"""
# lock stream output
- with self.lock:
- if not force:
- line_template = '{{0: >{}}}: {{1}}'.format(
- len(str(len(answers))))
- for i, entry in enumerate(answers, start=1):
- self.stream_output(line_template.format(i, entry))
+ # with self.lock: (T282962)
+ if not force:
+ line_template = '{{0: >{}}}: {{1}}'.format(len(str(len(answers))))
+ for i, entry in enumerate(answers, start=1):
+ self.output(line_template.format(i, entry))
- while True:
- choice = self.input(question, default=default, force=force)
+ while True:
+ choice = self.input(question, default=default, force=force)
- try:
- choice = int(choice) - 1
- except (TypeError, ValueError):
- if choice in answers:
- return choice
- choice = -1
+ try:
+ choice = int(choice) - 1
+ except (TypeError, ValueError):
+ if choice in answers:
+ return choice
+ choice = -1
- # User typed choice number
- if 0 <= choice < len(answers):
- return answers[choice]
+ # User typed choice number
+ if 0 <= choice < len(answers):
+ return answers[choice]
- if force:
- raise ValueError(
- 'Invalid value "{}" for default during force.'
- .format(default))
+ if force:
+ raise ValueError('Invalid value "{}" for default during force.'
+ .format(default))
- pywikibot.error('Invalid response')
+ pywikibot.error('Invalid response')
def editText(self, text: str, jumpIndex: Optional[int] = None,
highlight: Optional[str] = None):
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index b80d6fb..74c2be5 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -342,7 +342,7 @@
self.orig_raw_input = bot.ui._raw_input
self.orig_output = bot.ui.output
bot.ui._raw_input = lambda *args, **kwargs: 'dummy input'
- bot.ui.stream_output = self._capture_output
+ bot.ui.output = self._capture_output
self.old_cc_setting = config.cosmetic_changes_mylang_only
def tearDown(self):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/696497
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: I0dc8cee5512840b559c76458c02533d598a93c24
Gerrit-Change-Number: 696497
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693651 )
Change subject: fixing_redirects.py: Ignore ValueError
......................................................................
fixing_redirects.py: Ignore ValueError
Bug: T283403
Bug: T111513
Change-Id: Ic21cb6e0170734c653fbe9dafec7ea7fc25370ac
---
M scripts/fixing_redirects.py
1 file changed, 7 insertions(+), 1 deletion(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py
index 7cf01a8..f80e326 100755
--- a/scripts/fixing_redirects.py
+++ b/scripts/fixing_redirects.py
@@ -72,10 +72,16 @@
break
# Make sure that next time around we will not find this same hit.
curpos = m.start() + 1
+ # T283403
+ try:
+ is_interwikilink = mysite.isInterwikiLink(m.group('title'))
+ except ValueError:
+ pywikibot.exception()
+ continue
# ignore interwiki links, links in the disabled area
# and links to sections of the same page
if (m.group('title').strip() == ''
- or mysite.isInterwikiLink(m.group('title'))
+ or is_interwikilink
or isDisabled(text, m.start())):
continue
actualLinkPage = pywikibot.Page(targetPage.site, m.group('title'))
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693651
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: Ic21cb6e0170734c653fbe9dafec7ea7fc25370ac
Gerrit-Change-Number: 693651
Gerrit-PatchSet: 7
Gerrit-Owner: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693497 )
Change subject: [cleanup] Remove deprecated MultipleSitesBot site attribute
......................................................................
[cleanup] Remove deprecated MultipleSitesBot site attribute
Our MultipleSitesBot's site attribute has been deprecated for almost six years.
Without it the class is no different from a BaseBot.
The bot module's class hierarchy could probably due with some rethought, but
for the moment simply cleaning up the deprecated code.
Bug: T283209
Change-Id: If241556cba23eb34e3a5835d5c285e4973bf8c2f
---
M pywikibot/bot.py
M tests/bot_tests.py
2 files changed, 4 insertions(+), 41 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 33b89d4..54918d4 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1677,37 +1677,6 @@
information on only one site.
"""
- def __init__(self, **kwargs):
- """Initializer."""
- self._site = None
- super().__init__(**kwargs)
-
- @property
- @deprecated("the page's site property", since='20150615',
- future_warning=True)
- def site(self):
- """
- Return the site if it's set and ValueError otherwise.
-
- The site is only defined while in treat and it is preferred to use
- the page's site instead.
- """
- if self._site is None:
- raise ValueError('Requesting the site not while in treat is not '
- 'allowed.')
- return self._site
-
- def run(self):
- """Reset the bot's site after run."""
- super().run()
- self._site = None
-
- def init_page(self, item):
- """Define the site for this page."""
- page = super().init_page(item)
- self._site = page.site
- return page
-
class ConfigParserBot(BaseBot):
diff --git a/tests/bot_tests.py b/tests/bot_tests.py
index 53d9b96..df13919 100644
--- a/tests/bot_tests.py
+++ b/tests/bot_tests.py
@@ -10,7 +10,6 @@
import pywikibot
import pywikibot.bot
from pywikibot import i18n
-from pywikibot.tools import suppress_warnings
from tests.aspects import (
DefaultSiteTestCase,
@@ -120,13 +119,16 @@
Afterwards it calls post_treat so it's possible to do additional
checks.
+
+ Site attributes are only present on Bot and SingleSitesBot, not
+ MultipleSitesBot.
"""
def treat(page):
self.assertEqual(page, next(self._page_iter))
if self._treat_site is None:
self.assertFalse(hasattr(self.bot, 'site'))
self.assertFalse(hasattr(self.bot, '_site'))
- else:
+ elif not isinstance(self.bot, pywikibot.bot.MultipleSitesBot):
self.assertIsNotNone(self.bot._site)
self.assertEqual(self.bot.site, self.bot._site)
if self._treat_site:
@@ -223,23 +225,15 @@
self.bot.run()
self.assertEqual(self.bot.site, self._treat_site)
- @suppress_warnings('pywikibot.bot.MultipleSitesBot.site is deprecated')
def test_MultipleSitesBot(self):
"""Test MultipleSitesBot class."""
# Assert no specific site
self._treat_site = False
self.bot = pywikibot.bot.MultipleSitesBot(generator=self._generator())
- with self.assertRaisesRegex(AttributeError,
- self.CANT_SET_ATTRIBUTE_RE):
- self.bot.site = self.de
- with self.assertRaisesRegex(ValueError, self.NOT_IN_TREAT_RE):
- self.bot.site
self.bot.treat = self._treat(self._generator())
self.bot.exit = self._exit(4)
self.bot.run()
- with self.assertRaisesRegex(ValueError, self.NOT_IN_TREAT_RE):
- self.bot.site
def test_Bot(self):
"""Test normal Bot class."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693497
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: If241556cba23eb34e3a5835d5c285e4973bf8c2f
Gerrit-Change-Number: 693497
Gerrit-PatchSet: 4
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged