jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1338043?usp=email )
Change subject: filepage: Avoid constructing cached file revisions again
......................................................................
filepage: Avoid constructing cached file revisions again
Create FileInfo only when a revision is absent from the cache. Update
existing revisions in place to preserve their identity and metadata,
and avoid updating newly constructed revisions twice.
Change-Id: Ice145ad5bedbd13c2f6542a2675d86e8e8649e02
---
M pywikibot/page/_filepage.py
1 file changed, 4 insertions(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/page/_filepage.py b/pywikibot/page/_filepage.py
index dc31af8..5dfd7b5b 100644
--- a/pywikibot/page/_filepage.py
+++ b/pywikibot/page/_filepage.py
@@ -93,12 +93,11 @@
continue
ts_key = pywikibot.Timestamp.fromISOformat(file_rev['timestamp'])
- file_revision = self._file_revisions.get(ts_key)
- if file_revision is None:
- self._file_revisions[ts_key] = FileInfo(file_rev, self)
- else:
+ if ts_key in self._file_revisions:
# add new imageinfo attributes since last request.
- file_revision.update(file_rev)
+ self._file_revisions[ts_key].update(file_rev)
+ else:
+ self._file_revisions[ts_key] = FileInfo(file_rev, self)
@property
def latest_file_info(self):
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1338043?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: Ice145ad5bedbd13c2f6542a2675d86e8e8649e02
Gerrit-Change-Number: 1338043
Gerrit-PatchSet: 3
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]