Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/699420 )
Change subject: [cleanup] deprecate get_text, put_text and add_text functions ......................................................................
[cleanup] deprecate get_text, put_text and add_text functions
Also remove tests of deprecated functions.
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/699385 must be merged first!
Bug: T284388 Change-Id: I5d9c6f3ae29ebcb9e91b5f3c0331fc8b2e831fae --- M scripts/add_text.py M tests/add_text_tests.py 2 files changed, 9 insertions(+), 23 deletions(-)
Approvals: jenkins-bot: Verified Damian: Looks good to me, but someone else must approve Xqt: Looks good to me, approved
diff --git a/scripts/add_text.py b/scripts/add_text.py index 509a11c..f565538 100755 --- a/scripts/add_text.py +++ b/scripts/add_text.py @@ -74,6 +74,7 @@ ServerError, SpamblacklistError, ) +from pywikibot.tools import deprecated from pywikibot.tools.formatter import color_format
DEFAULT_ARGS = { @@ -98,6 +99,8 @@ docuReplacements = {'¶ms;': pagegenerators.parameterHelp} # noqa: N816
+@deprecated('Page.text, NoRedirectPageBot class and BaseBot.skip_page() ' + '(see add_text.AddTextBot for example)', since='6.4.0') def get_text(page: pywikibot.page.BasePage, old: Optional[str], create: bool) -> str: """ @@ -126,6 +129,7 @@ return None
+@deprecated('BaseBot.userPut()', since='6.4.0') def put_text(page: pywikibot.page.BasePage, new: str, summary: str, count: int, asynchronous: bool = False) -> Optional[bool]: """ @@ -165,6 +169,9 @@ return False
+@deprecated('Page.text, textlib.add_text, NoRedirectPageBot class, ' + 'BaseBot.skip_page() and CurrentPage.put_current() ' + '(see add_text.AddTextBot for example)', since='6.4.0') def add_text(page: pywikibot.page.BasePage, addText: str, summary: Optional[str] = None, regexSkip: Optional[str] = None, diff --git a/tests/add_text_tests.py b/tests/add_text_tests.py index 7a15450..18ad26a 100644 --- a/tests/add_text_tests.py +++ b/tests/add_text_tests.py @@ -10,7 +10,8 @@ import pywikibot import pywikibot.pagegenerators
-from scripts.add_text import add_text, get_text, parse +from scripts.add_text import parse + from tests.aspects import TestCase
@@ -79,28 +80,6 @@ self.assertEqual('hello world', args['text']) input_mock.assert_called_with('What text do you want to add?')
- def test_basic(self): - """Test adding text.""" - (_, newtext, _) = add_text( - self.page, 'bar', putText=False, - oldTextGiven='foo\n{{linkfa}}') - self.assertEqual( - 'foo\n{{linkfa}}\nbar', - newtext) - - def test_with_category(self): - """Test adding text before categories.""" - (_, newtext, _) = add_text( - self.page, 'bar', putText=False, - oldTextGiven='foo\n[[Category:Foo]]') - self.assertEqual( - 'foo\nbar\n\n[[Category:Foo]]', - newtext) - - def test_get_text(self): - """Test get_text with given text.""" - self.assertEqual(get_text(self.page, 'foo', False), 'foo') -
if __name__ == '__main__': # pragma: no cover unittest.main()