From: W. Trevor King Date: Sun, 30 Jun 2013 18:14:08 +0000 (-0400) Subject: entry: Hash entries by their UID (when possible) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=83ca807a9e0d2a16eff850f050a5e85630d091b1;p=pycalendar.git 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. --- 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):