entry: Add Feed.get_geo for parsing the GEO field
[pycalendar.git] / pycalendar / entry.py
index 88a6b359b48f9a8c4932eecd31e161c23834b11a..c0de9902c82645a306194242f1b64fd16096fa3c 100644 (file)
@@ -207,5 +207,15 @@ class Entry (dict):
         value = self.get(*args, **kwargs)
         return _text.unescape(value)
 
+    def get_geo(self, key='GEO', *args, **kwargs):
+        """Get and unescape a GEO value
+
+        As described in :RFC:`5545`, section 3.8.1.6 (Geographic
+        Position).
+        """
+        value = self.get(key, *args, **kwargs)
+        lat,lon = [float(x) for x in value.split(';')]
+        return (lat, lon)
+
     def write(self, stream):
         stream.write(self.content)