Lokal Profil has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/342494 )

Change subject: [WIP][BUG]Correctly compare Coordinate
......................................................................

[WIP][BUG]Correctly compare Coordinate

Current comparison of Coordinate requires `_entity` to be set and
also compares `globe`. As these can take multiple forms yet still
be equivalent a separate `__eq__` is needed.

This is similar to the solution required for WbQuantity.

WIP pending:
* https://gerrit.wikimedia.org/r/#/c/334912/
* Tests

Bug:T160282
Change-Id: I6584e60782db554da46736cc9f12f47772ed91b1
---
M pywikibot/__init__.py
1 file changed, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/94/342494/1

diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 273e538..43a57fb 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -235,6 +235,18 @@
 
     _items = ('lat', 'lon', 'globe')
 
+    def __eq__(self, other):
+        """Override equality to handle different globe representations."""
+        if isinstance(other, self.__class__):
+            self_dict = self.__dict__.copy()
+            other_dict = other.__dict__.copy()
+            self_dict['_entity'] = self.entity
+            other_dict['_entity'] = other.entity
+            del self_dict['globe']
+            del other_dict['globe']
+            return self_dict == other_dict
+        return NotImplemented
+
     def __init__(self, lat, lon, alt=None, precision=None, globe='earth',
                  typ="", name="", dim=None, site=None, entity=''):
         """

-- 
To view, visit https://gerrit.wikimedia.org/r/342494
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6584e60782db554da46736cc9f12f47772ed91b1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to