Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
authorFredrik Wendt <fredrik@wendt.se>
Wed, 9 Jun 2010 16:16:59 +0000 (17:16 +0100)
committerFredrik Wendt <fredrik@wendt.se>
Wed, 9 Jun 2010 16:16:59 +0000 (17:16 +0100)
Signed-off-by: Fredrik Wendt <fredrik@wendt.se>

package/src/org/maemo/hermes/engine/friend.py

index 32ee3c2..6bd71f2 100644 (file)
@@ -16,29 +16,28 @@ class Friend():
         return self.__repr__()
     
     def __repr__(self):
-        return "Friend %s" % self._attributes['fn']
+        return "Friend %s" % self.get_name()
     
     # public accessors -----------------
     
     def get_contact(self):
-        return self._attributes['contact']
+        return self._safe_get('contact')
     
     def get_name(self):
-        return self._attributes['fn']
+        return self._safe_get('fn')
     
     def get_source(self):
         return self._source
     
     def get_nickname(self):
-        return self._attributes["nickname"]
+        return self._safe_get("nickname")
     
     def get_urls(self):
         try: return self._multi_attributes['url'] 
         except: return []
         
     def get_photo_url(self):
-        try: return self._attributes['photo-url']
-        except: return None
+        return self._safe_get('photo-url')
     
     def add_url(self, url):
         self._add('url', url)
@@ -126,4 +125,9 @@ class Friend():
         return False
     
     def __getitem__(self, key):
-        return self._attributes[key]
+        return self._safe_get(key)
+                              
+    def _safe_get(self, key):
+        try: return self._attributes[key]
+        except: return None
+        

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment