jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/661340 )
Change subject: [doc] Update ROADMAP.rst
......................................................................
[doc] Update ROADMAP.rst
Change-Id: I57cc3db3d98480d98833d068606ec11be65c986d
---
M ROADMAP.rst
1 file changed, 8 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index d2b9666..684b401 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -4,12 +4,20 @@
Breaking changes
^^^^^^^^^^^^^^^^
+* Support of MediaWiki < 1.23 has been dropped (T268979)
+* APISite.loadimageinfo will no longer return any content
* Return requests.Response with http.request() instead of plain text (T265206)
* config.db_hostname has been renamed to db_hostname_format
Other changes
^^^^^^^^^^^^^
+* Create a SiteLink with __getitem__ method and implement lazy load (T273386, T245809, T238471, T226157)
+* Fix date.formats['MonthName'] behaviour (T273573)
+* Deprecated Family.known_families dict was removed (T89451)
+* Implement pagegenerators.handle_args() to process all options at once
+* Deprecated DataSite.get_* methods was removed
+* Deprecated LogEntryFactory.logtypes classproperty was removed
* Add enabled_options, disabled_options to GeneratorFactory (T271320)
* Move interwiki() interwiki_prefix() and local_interwiki() methods from BaseSite to APISite
* Add requests.Response.headers to log when an API error occurs (T272325)
@@ -23,10 +31,8 @@
* 5.5.0: Deprecated data attribute of http.fetch() result will be given up (T265206)
* 5.5.0: Site.getuserinfo() method will be dropped in favour of userinfo property
* 5.5.0: Site.getglobaluserinfo() method will be dropped in favour of globaluserinfo property
-* 5.4.0: Support of MediaWiki < 1.23 will be dropped with release 6.0 (T268979)
* 5.4.0: LoginManager.getCookie() is deprecated and will be removed
* 5.4.0: tools.PY2 will be removed (T213287)
-* 5.3.0: LogEntryFactory.logtypes property will be removed
* 5.3.0: toStdout parameter of logging.output()/pywikibot.output() function will be desupported
* 5.0.0: OptionHandler.options dict will be removed in favour of OptionHandler.opt
* 5.0.0: Methods deprecated for 5 years or longer will be removed
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/661340
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: I57cc3db3d98480d98833d068606ec11be65c986d
Gerrit-Change-Number: 661340
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/+/660809 )
Change subject: [IMPR] Create a SiteLink with __getitem__ method
......................................................................
[IMPR] Create a SiteLink with __getitem__ method
SiteLinkCollection initializer updates data contents to self._data
dict. The update method calls __setitem__ for each data entry; for
each entry a SiteLink is created which needs a siteinfo content for
every affected site and leads to a huge loading time.
Now with this patch the SiteLink object is created when the link
is fetched from self._data via __getitem__ or __iter__ method.
This prevents siteinfo content for each site from loading even
a link is currently not used and decrease loading time a lot.
Bug: T245809
Bug: T226157
Bug: T238471
Bug: T273386
Change-Id: Icc92cfd5d200fde47eb127e2fe601f812427624a
---
M pywikibot/page/__init__.py
M tests/wikibase_tests.py
2 files changed, 20 insertions(+), 12 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 912f619..be8b2ce 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -3528,23 +3528,33 @@
@rtype: pywikibot.page.SiteLink
"""
key = self.getdbName(key)
- return self._data[key]
+ val = self._data[key]
+ if isinstance(val, str):
+ val = SiteLink(val, key)
+ elif isinstance(val, dict):
+ val = SiteLink.fromJSON(val, self.repo)
+ else:
+ return val
+ self._data[key] = val
+ return val
def __setitem__(self, key, val):
"""
Set the SiteLink for a given key.
+ This only sets the value given as str, dict or SiteLink. If a
+ str or dict is given the SiteLink object is created later in
+ __getitem__ method.
+
@param key: site key as Site instance or db key
@type key: pywikibot.Site or str
- @param val: page name as a string or JSON containing SiteLink data
- @type val: dict or str
- @rtype: pywikibot.page.SiteLink
+ @param val: page name as a string or JSON containing SiteLink
+ data or a SiteLink object
+ @type val: Union[str, dict, SiteLink]
"""
- if isinstance(val, str):
- val = SiteLink(val, key)
- else:
- val = SiteLink.fromJSON(val, self.repo)
key = self.getdbName(key)
+ if isinstance(val, SiteLink):
+ assert val.site.dbName() == key
self._data[key] = val
def __delitem__(self, key):
@@ -3851,8 +3861,8 @@
self.latest_revision_id = self._content.get('lastrevid')
data = {}
- # todo: this initializes all data,
- # make use of lazy initialization (T245809)
+
+ # This initializes all data,
for key, cls in self.DATA_ATTRIBUTES.items():
value = cls.fromJSON(self._content.get(key, {}), self.repo)
setattr(self, key, value)
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index f77af864..6a9740b 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -2352,8 +2352,6 @@
"""Test cases to test toJSON() functions."""
- dry = True
-
def setUp(self):
"""Setup test."""
super().setUp()
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/660809
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: Icc92cfd5d200fde47eb127e2fe601f812427624a
Gerrit-Change-Number: 660809
Gerrit-PatchSet: 8
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Bugreporter <bugreporter1(a)sina.com>
Gerrit-Reviewer: JAn Dudík <jan.dudik(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-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/660758 )
Change subject: [IMPR] speed up preload_sites.py maintenance script
......................................................................
[IMPR] speed up preload_sites.py maintenance script
Increase the number of parallel workers. For example siteinfo of all
750 sites can be preloaded in 20 seconds with 25 workers.
Bug: T226157
Change-Id: I9e4f8810f4a969fb58a397f94add52ace293d25b
---
M scripts/maintenance/preload_sites.py
1 file changed, 7 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/preload_sites.py b/scripts/maintenance/preload_sites.py
index 5eb4f2a..f44aad3 100644
--- a/scripts/maintenance/preload_sites.py
+++ b/scripts/maintenance/preload_sites.py
@@ -43,7 +43,7 @@
}
-def preload_family(family):
+def preload_family(family, executor):
"""Preload all sites of a single family file."""
msg = 'Preloading sites of {} family{}'
pywikibot.output(msg.format(family, '...'))
@@ -54,11 +54,13 @@
codes.remove(code)
obsolete = Family.load(family).obsolete
+ futures = set()
for code in codes:
if code not in obsolete:
site = pywikibot.Site(code, family)
- pywikibot.Page(site, 'Main page') # title does not care
-
+ # page title does not care
+ futures.add(executor.submit(pywikibot.Page, site, 'Main page'))
+ wait(futures)
pywikibot.output(msg.format(family, ' completed.'))
@@ -66,8 +68,8 @@
"""Preload all sites of all given family files."""
start = datetime.now()
with ThreadPoolExecutor(worker) as executor:
- futures = {executor.submit(preload_family, family):
- family for family in families}
+ futures = {executor.submit(preload_family, family, executor)
+ for family in families}
wait(futures)
pywikibot.output('Loading time used: {}'.format(datetime.now() - start))
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/660758
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: I9e4f8810f4a969fb58a397f94add52ace293d25b
Gerrit-Change-Number: 660758
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged