jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/622811 )
Change subject: [bugfix] Clean up ProofreadPage.text
......................................................................
[bugfix] Clean up ProofreadPage.text
BasePage._text doesn't cache the live content anymore,
so don't rely on the internal side effect and just
return the value from the parent.
Bug: T260472
Change-Id: I21e4f234ac75237524d1d8c29c07efe0c45040bf
---
M pywikibot/proofreadpage.py
1 file changed, 7 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 8976b43..bf1858b 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -412,15 +412,16 @@
pages.
"""
# Text is already cached.
- if hasattr(self, '_text'):
+ if getattr(self, '_text', None) is not None:
return self._text
- # If page does not exist, preload it.
+
if self.exists():
# If page exists, load it.
- super().text
- else:
- self._text = self.preloadText()
- self.user = self.site.username() # Fill user field in empty header
+ return super().text
+
+ # If page does not exist, preload it.
+ self._text = self.preloadText()
+ self.user = self.site.username() # Fill user field in empty header
return self._text
@text.setter
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/622811
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: I21e4f234ac75237524d1d8c29c07efe0c45040bf
Gerrit-Change-Number: 622811
Gerrit-PatchSet: 1
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(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/+/622803 )
Change subject: [doc] Update ROADMAP.rst
......................................................................
[doc] Update ROADMAP.rst
Change-Id: Ib8dd000b1e7c01c89f8b25f1ab85ccb0ae553810
---
M ROADMAP.rst
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index a5935fa..f8f12f3 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,6 +1,9 @@
Current release changes
~~~~~~~~~~~~~~~~~~~~~~~
+* Only run cosmetic changes on wikitext pages (T260489)
+* Leave a script gracefully for wrong -lang and -family option (T259756)
+* Change meaning of BasePage.text (T260472)
* site/family methods code2encodings() and code2encoding() has been removed in favour of encoding()/endcodings() methods
* Site.getExpandedString() method was removed in favour of expand_text
* Site.Family() function was removed in favour of Family.load() method
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/622803
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: Ib8dd000b1e7c01c89f8b25f1ab85ccb0ae553810
Gerrit-Change-Number: 622803
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/622786 )
Change subject: Re-apply "Only run cosmetic changes on wikitext pages"
......................................................................
Re-apply "Only run cosmetic changes on wikitext pages"
This reverts commit 33aebee955995c1efd477a885d28db4995d171e4.
Bug: T260489
Change-Id: I3ecb38eb332f34f680e90071d2bcf38ceb18c5ea
---
M pywikibot/page/__init__.py
1 file changed, 7 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 2610429..6ccc83b 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -1308,7 +1308,7 @@
cc=None, quiet=False, **kwargs):
"""Helper function for save()."""
link = self.title(as_link=True)
- if cc or cc is None and config.cosmetic_changes:
+ if cc or (cc is None and config.cosmetic_changes):
summary = self._cosmetic_changes_hook(summary)
done = self.site.editpage(self, summary=summary, minor=minor,
@@ -1329,20 +1329,18 @@
else the old edit summary.
@rtype: str
"""
- if self.isTalkPage() or \
+ if self.isTalkPage() or self.content_model != 'wikitext' or \
pywikibot.calledModuleName() in config.cosmetic_changes_deny_script:
return summary
family = self.site.family.name
if config.cosmetic_changes_mylang_only:
- cc = ((family == config.family
- and self.site.lang == config.mylang)
- or family in config.cosmetic_changes_enable
- and self.site.lang in config.cosmetic_changes_enable[family])
+ cc = ((family == config.family and self.site.lang == config.mylang)
+ or self.site.lang in config.cosmetic_changes_enable.get(
+ family, []))
else:
cc = True
- cc = (cc and not
- (family in config.cosmetic_changes_disable
- and self.site.lang in config.cosmetic_changes_disable[family]))
+ cc = cc and self.site.lang not in config.cosmetic_changes_disable.get(
+ family, [])
if not cc:
return summary
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/622786
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: I3ecb38eb332f34f680e90071d2bcf38ceb18c5ea
Gerrit-Change-Number: 622786
Gerrit-PatchSet: 3
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(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/+/618702 )
Change subject: [IMPR] Leave the script gracefully for wrong -lang and -family option
......................................................................
[IMPR] Leave the script gracefully for wrong -lang and -family option
- If the site given by -lang and -family option does not exists
show an error message and leave immediately, instead of printing
a full traceback after the script has started.
- Update script_tests.py to that pywikibot.Site is a function instead
of None.
Bug: T259756
Change-Id: I7474b6776625b45ccda07305d70764f8aefa6c05
---
M pywikibot/bot.py
M tests/script_tests.py
2 files changed, 9 insertions(+), 4 deletions(-)
Approvals:
Zoranzoki21: Looks good to me, but someone else must approve
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 7e01efe..dad67ad 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -113,9 +113,8 @@
ChoiceException, QuitKeyboardInterrupt,
Choice, StaticChoice, LinkChoice, AlwaysChoice
)
-from pywikibot.logging import (
- CRITICAL, ERROR, INFO, WARNING,
-)
+from pywikibot.exceptions import UnknownFamily, UnknownSite
+from pywikibot.logging import CRITICAL, ERROR, INFO, WARNING
from pywikibot.logging import DEBUG, INPUT, STDOUT, VERBOSE
from pywikibot.logging import (
add_init_routine,
@@ -875,6 +874,12 @@
# argument not global -> specific bot script will take care
non_global_args.append(arg)
+ try:
+ pywikibot.Site()
+ except (UnknownFamily, UnknownSite):
+ pywikibot.exception()
+ sys.exit(1)
+
if username:
config.usernames[config.family][config.mylang] = username
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 8e64326..61c996a 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -228,7 +228,7 @@
test_overrides = {}
if not hasattr(self, 'net') or not self.net:
- test_overrides['pywikibot.Site'] = 'None'
+ test_overrides['pywikibot.Site'] = 'lambda *a, **k: None'
# run the script
result = execute_pwb(cmd, data_in, timeout=timeout,
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/618702
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: I7474b6776625b45ccda07305d70764f8aefa6c05
Gerrit-Change-Number: 618702
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/620503 )
Change subject: [bugfix] Change meaning of BasePage.text
......................................................................
[bugfix] Change meaning of BasePage.text
- BasePage._text now only caches content saved using
the setter of BasePage.text. Caching two distinct
things in a single property was source of the
confusion behind the problem. Since Revisions are
immutable (or should be), the live content is cached
in the latest revision object.
- BasePage.text returns BasePage._text if it is set,
otherwise returns the live content.
- If BasePage._text has been set and the caller wants
to work with the live content, they should use
BasePage.get() or set BasePage.text to None first.
Since _text doesn't cache live content anymore, do not
delete it when page information is loaded.
Bug: T260472
Change-Id: I8c8fbcd57998ea3d68e047cf6e5a0a1241156ceb
---
M pywikibot/data/api.py
M pywikibot/page/__init__.py
M tests/basepage_tests.py
3 files changed, 36 insertions(+), 14 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 122f5fd..fd72de1 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -3394,7 +3394,6 @@
if 'lastrevid' in pagedict:
page.latest_revision_id = pagedict['lastrevid']
- del page.text
if 'imageinfo' in pagedict:
assert(isinstance(page, pywikibot.FilePage))
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index a286f29..2610429 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -609,13 +609,13 @@
@return: text of the page
@rtype: str
"""
- if not hasattr(self, '_text') or self._text is None:
- try:
- self._text = self.get(get_redirect=True)
- except pywikibot.NoPage:
- # TODO: what other exceptions might be returned?
- self._text = ''
- return self._text
+ if getattr(self, '_text', None) is not None:
+ return self._text
+ try:
+ return self.get(get_redirect=True)
+ except pywikibot.NoPage:
+ # TODO: what other exceptions might be returned?
+ return ''
@text.setter
def text(self, value):
@@ -625,9 +625,8 @@
@param value: New value or None
@type value: basestring
"""
+ del self.text
self._text = None if value is None else str(value)
- if hasattr(self, '_raw_extracted_templates'):
- del self._raw_extracted_templates
@text.deleter
def text(self):
@@ -1452,6 +1451,8 @@
minor and botflag parameters are set to False which prevents hiding
the edit when it becomes a real edit due to a bug.
+
+ @note: This discards content saved to self.text.
"""
if self.exists():
# ensure always get the page text and not to change it.
diff --git a/tests/basepage_tests.py b/tests/basepage_tests.py
index 8964049..98c1443 100644
--- a/tests/basepage_tests.py
+++ b/tests/basepage_tests.py
@@ -53,6 +53,11 @@
self.assertTrue(hasattr(page, '_revisions'))
self.assertFalse(page._revisions)
+ # verify that initializing the page content
+ # does not discard the custom text
+ custom_text = 'foobar'
+ page.text = custom_text
+
self.site.loadrevisions(page, total=1)
self.assertTrue(hasattr(page, '_revid'))
@@ -60,25 +65,42 @@
self.assertLength(page._revisions, 1)
self.assertIn(page._revid, page._revisions)
+ self.assertEqual(page._text, custom_text)
+ self.assertEqual(page.text, page._text)
+ del page.text
+
self.assertFalse(hasattr(page, '_text'))
self.assertIsNone(page._revisions[page._revid].text)
self.assertFalse(hasattr(page, '_text'))
self.assertIsNone(page._latest_cached_revision())
+ page.text = custom_text
+
self.site.loadrevisions(page, total=1, content=True)
- self.assertFalse(hasattr(page, '_text'))
+
self.assertIsNotNone(page._latest_cached_revision())
+ self.assertEqual(page._text, custom_text)
+ self.assertEqual(page.text, page._text)
+ del page.text
+ self.assertFalse(hasattr(page, '_text'))
# Verify that calling .text doesn't call loadrevisions again
loadrevisions = self.site.loadrevisions
try:
self.site.loadrevisions = None
- self.assertIsNotNone(page.text)
+ loaded_text = page.text
+ self.assertIsNotNone(loaded_text)
+ self.assertFalse(hasattr(page, '_text'))
+ page.text = custom_text
+ self.assertEqual(page.get(), loaded_text)
+ self.assertEqual(page._text, custom_text)
+ self.assertEqual(page.text, page._text)
+ del page.text
+ self.assertFalse(hasattr(page, '_text'))
+ self.assertEqual(page.text, loaded_text)
finally:
self.site.loadrevisions = loadrevisions
- self.assertTrue(hasattr(page, '_text'))
-
class BasePageMethodsTestBase(BasePageTestBase):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/620503
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: I8c8fbcd57998ea3d68e047cf6e5a0a1241156ceb
Gerrit-Change-Number: 620503
Gerrit-PatchSet: 7
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-CC: Huji <huji.huji(a)gmail.com>
Gerrit-CC: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/621878 )
Change subject: [bugfix] _paraminfo and _siteinfo gives different languages results
......................................................................
[bugfix] _paraminfo and _siteinfo gives different languages results
The results of _paraminfo and _siteinfo are no longer the same with
mw 1.36.0-wmf5. test_language_lists is no longer required.
- use _paraminfo for DataSite.search_entities intead of _siteinfo
to get languages codes.
- remove TestDataSiteSearchEntities.test_language_lists
Bug: T261038
Change-Id: Ib827314d7340d440e08a532d7ae861267b1b114d
---
M pywikibot/site/__init__.py
M tests/site_tests.py
2 files changed, 4 insertions(+), 13 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py
index 1954af5..3c29120 100644
--- a/pywikibot/site/__init__.py
+++ b/pywikibot/site/__init__.py
@@ -8250,21 +8250,21 @@
return pywikibot.ItemPage(self, result['entity']['id'])
@deprecated_args(limit='total')
- def search_entities(self, search, language, total=None, **kwargs):
+ def search_entities(self, search: str, language: str, total=None,
+ **kwargs):
"""
Search for pages or properties that contain the given text.
@param search: Text to find.
- @type search: str
@param language: Language to search in.
- @type language: str
@param total: Maximum number of pages to retrieve in total, or None in
case of no limit.
@type total: int or None
@return: 'search' list from API output.
@rtype: api.APIGenerator
"""
- lang_codes = [lang['code'] for lang in self._siteinfo.get('languages')]
+ lang_codes = self._paraminfo.parameter('wbsearchentities',
+ 'language')['type']
if language not in lang_codes:
raise ValueError('Data site used does not support provided '
'language.')
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 1467d84..586a8be 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -3413,15 +3413,6 @@
pages_continue = datasite.search_entities('Rembrandt', 'en', **kwargs)
self.assertNotEqual(list(pages), list(pages_continue))
- def test_language_lists(self):
- """Test that languages returned by paraminfo and MW are the same."""
- site = self.get_site()
- lang_codes = site._paraminfo.parameter('wbsearchentities',
- 'language')['type']
- lang_codes2 = [lang['code']
- for lang in site._siteinfo.get('languages')]
- self.assertEqual(lang_codes, lang_codes2)
-
def test_invalid_language(self):
"""Test behavior of search_entities with invalid language provided."""
datasite = self.get_repo()
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/621878
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: Ib827314d7340d440e08a532d7ae861267b1b114d
Gerrit-Change-Number: 621878
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/621526 )
Change subject: [doc] Update ROADMAP.rst
......................................................................
[doc] Update ROADMAP.rst
Change-Id: Ic416f545d24d8e6b18a4b07446db780576777fa0
---
M ROADMAP.rst
1 file changed, 4 insertions(+), 3 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index bdd50c8..a5935fa 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,20 +1,21 @@
Current release changes
~~~~~~~~~~~~~~~~~~~~~~~
+* site/family methods code2encodings() and code2encoding() has been removed in favour of encoding()/endcodings() methods
+* Site.getExpandedString() method was removed in favour of expand_text
+* Site.Family() function was removed in favour of Family.load() method
* Add wikispore family (T260049)
Future release notes
~~~~~~~~~~~~~~~~~~~~
+* 4.2.0: tools.StringTypes will be removed
* 4.1.0: Deprecated editor.command will be removed
* 4.1.0: tools.open_compressed, tools.UnicodeType and tools.signature will be removed
* 4.1.0: comms.PywikibotCookieJar and comms.mode_check_decorator will be removed
* 4.0.0: Deprecated tools.UnicodeMixin and tools.IteratorNextMixin will be removed
-* 4.0.0: Site.Family() function will be removed in favour of Family.load() method
-* 4.0.0: Site.getExpandedString method will be removed in favour of expand_text
* 4.0.0: Unused parameters of page methods like forceReload, insite, throttle, step will be removed
-* 4.0.0: site/family methods code2encodings and code2encoding will be removed in favour of encoding/endcodings methods
* 4.0.0: Methods deprecated for 6 years or longer will be removed
* 3.0.20200508: Page.getVersionHistory and Page.fullVersionHistory() methods will be removed (T136513, T151110)
* 3.0.20200306: Support of MediaWiki releases below 1.19 will be dropped (T245350)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/621526
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: Ic416f545d24d8e6b18a4b07446db780576777fa0
Gerrit-Change-Number: 621526
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Jayprakash12345 <0freerunning(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-MessageType: merged