Ladsgroup has uploaded a new change for review. https://gerrit.wikimedia.org/r/236261
Change subject: Add __eq__ and add self.id based on title ...................................................................... Add __eq__ and add self.id based on title Change-Id: I5312d47e53c2444c8645ba094edc057d9c03cfe9 --- M pywikibase/claim.py M pywikibase/itempage.py M pywikibase/wikibasepage.py 3 files changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/wikibase refs/changes/61/236261/1 diff --git a/pywikibase/claim.py b/pywikibase/claim.py index 9fc5887..b0bf449 100644 --- a/pywikibase/claim.py +++ b/pywikibase/claim.py @@ -145,6 +145,10 @@ return cls.fromJSON({'mainsnak': data, 'hash': data['hash']}) + def __eq__(self, other): + return other.toJSON() == self.toJSON() + + def toJSON(self): """ Create dict suitable for the MediaWiki API. diff --git a/pywikibase/itempage.py b/pywikibase/itempage.py index a789858..b072e8d 100644 --- a/pywikibase/itempage.py +++ b/pywikibase/itempage.py @@ -40,6 +40,7 @@ raise RuntimeError( u"'%s' is not a valid item page title" % title) + self.id = title def get(self, *args, **kwargs): """ diff --git a/pywikibase/wikibasepage.py b/pywikibase/wikibasepage.py index 0bdbe1f..6f3d2b7 100644 --- a/pywikibase/wikibasepage.py +++ b/pywikibase/wikibasepage.py @@ -23,6 +23,10 @@ There should be no need to instantiate this directly. """ + def __eq__(self, other): + return other.id == self.id + + def get(self, content=None): """ Fetch all page data, and cache it. -- To view, visit https://gerrit.wikimedia.org/r/236261 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5312d47e53c2444c8645ba094edc057d9c03cfe9 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/wikibase Gerrit-Branch: master Gerrit-Owner: Ladsgroup <ladsgr...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits