entry: Hash entries by their UID (when possible)
[pycalendar.git] / pycalendar / entry.py
index 90e0bac0b060cf64c301abf86b9346fa60bc9a74..315a2284080607f36ca061d45619dc3c966d4a63 100644 (file)
@@ -69,6 +69,13 @@ class Entry (dict):
             self.process()
 
     def __hash__(self):
+        if self.type in [
+                'VEVENT',
+                'VFREEBUSY',
+                'VJOURNAL',
+                'VTODO',
+                ] or 'UID' in self:
+            return hash(_text.unescape(self['UID']))
         return id(self)
 
     def __str__(self):