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 17:13:05 +0000 (18:13 +0100)
committerFredrik Wendt <fredrik@wendt.se>
Wed, 9 Jun 2010 17:13:05 +0000 (18:13 +0100)
Signed-off-by: Fredrik Wendt <fredrik@wendt.se>

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

index 6bd71f2..ff4cd05 100644 (file)
@@ -12,6 +12,9 @@ class Friend():
         self._multi_attributes = {}
         self._source = source 
         
+    def __getitem__(self, key):
+        return self._safe_get(key)
+                              
     def __unicode__(self):
         return self.__repr__()
     
@@ -20,6 +23,12 @@ class Friend():
     
     # public accessors -----------------
     
+    def add_url(self, url):
+        self._add('url', url)
+        
+    def get_birthday_date(self):
+        return self._safe_get('bday')
+    
     def get_contact(self):
         return self._safe_get('contact')
     
@@ -39,9 +48,9 @@ class Friend():
     def get_photo_url(self):
         return self._safe_get('photo-url')
     
-    def add_url(self, url):
-        self._add('url', url)
-        
+    def has_birthday_date(self):
+        return self._has('bday')
+    
     def is_empty(self):
         for a in self._attributes:
             return False
@@ -49,9 +58,6 @@ class Friend():
             return False
         return True
     
-    def has_birthday_date(self):
-        return self._has('bday')
-    
     def set_name(self, name):
         self._set('fn', name)
     
@@ -67,7 +73,7 @@ class Friend():
     def set_photo_url(self, url):
         self._set('photo-url', url)
     
-    def update(self, other_friend):
+    def update(self, other_friend, overwrite=False):
         """
         Overwrites any attributes in this friend, with attributes from other_friend
         """
@@ -98,15 +104,6 @@ class Friend():
 
     # private helpers -----------------------
     #
-    def _if_defined(self, key, callback):
-        if self._attributes.has_key(key):
-            callback(self._attributes[key])
-    
-    def _set(self, key, value):
-        if value is not None:
-#            print "%s SET %s to %s" % (self, key, value)
-            self._attributes[key] = value
-    
     def _add(self, key, value):
         if value is not None:
             if not self._multi_attributes.has_key(key):
@@ -114,9 +111,6 @@ class Friend():
 #            print "%s ADD %s to %s" % (self, key, value)
             self._multi_attributes[key].append(value)
     
-    def _has(self, key):
-        return self._attributes.has_key(key) or self._multi_attributes.has_key(key)
-    
     def _contains(self, key, value):
         if self._attributes.has_key(key):
             return value == self._attributes[key]
@@ -124,10 +118,19 @@ class Friend():
             return value in self._multi_attributes[key]
         return False
     
-    def __getitem__(self, key):
-        return self._safe_get(key)
-                              
+    def _if_defined(self, key, callback):
+        if self._attributes.has_key(key):
+            callback(self._attributes[key])
+    
+    def _has(self, key):
+        return self._attributes.has_key(key) or self._multi_attributes.has_key(key)
+    
     def _safe_get(self, key):
         try: return self._attributes[key]
         except: return None
         
+    def _set(self, key, value):
+        if value is not None:
+#            print "%s SET %s to %s" % (self, key, value)
+            self._attributes[key] = value
+    

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment