From 83ca807a9e0d2a16eff850f050a5e85630d091b1 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 30 Jun 2013 14:14:08 -0400 Subject: [PATCH] entry: Hash entries by their UID (when possible) From RFC 5545, section 3.8.4.7 (Unique Identifier): Conformance: The property MUST be specified in the "VEVENT", "VTODO", "VJOURNAL", or "VFREEBUSY" calendar components. --- pycalendar/entry.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pycalendar/entry.py b/pycalendar/entry.py index 90e0bac..315a228 100644 --- a/pycalendar/entry.py +++ b/pycalendar/entry.py @@ -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): -- 2.26.2