Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
a37a9a8fe7534202b9e4689db8e6dfaedf8eaf94
1 class Hermes:
2     """Encapsulate the process of syncing online friends' information with the
3        Evolution contacts' database. This should be used as follows:
4        
5          * Initialise, passing in a GUI callback.
6          * Call Syncjob.
7          * Retrieve information on changes effected.
8          * Call update_contact to enact manual mapping.
9          
10        Copyright (c) Andrew Flegg <andrew@bleb.org> 2010.
11        Released under the Artistic Licence."""
13     
14     # -----------------------------------------------------------------------
15     def __init__(self, services, gui_progress):
16         """Constructor. Passed a list of services, and a callback method
17            which must implement the following API.
18                               
19              progress(i, j) - the application is currently processing friend 'i' of
20                               'j'. Should be used to provide the user a progress bar.
21         """
22         
23         # -- These fields are currently part of the API...
24         #
25         self.updated   = []
26         self.matched   = []
27         self.unmatched = []
28         self.friends   = {}
29         self.addresses = None
30         
31         # -- Other initialisation...
32         #
33         self._services = services
34         self._progress = gui_progress
35     
36     
37     # -----------------------------------------------------------------------
38     def run(self, resync = False):
39         """Load information on the authenticated user's friends. Synchronise Facebook
40            profiles to contact database. If resync is false, no existing information
41            will be overwritten."""
43         class FakeContact():
44             def get_name(self):
45                 return "Fredrik Wendt"
46             def get_emails(self):
47                 return ["fredrik@wendt.se","maemohermes@wendt.se"]
48             def get_photo(self):
49                 return None
50         self.matched = [FakeContact()]
51  
52 #        self._sync_job = SyncJob(services, [FakeContact()], self.progress)
53 #        self._sync_job.run()
54 #        self._sync_job.get_unmatched_friends()
55 #        self._sync_job.get_updated_contacts()
56 #        self._sync_job.get_matched_contacts()
57         pass
60     # -----------------------------------------------------------------------
61     def update_contact(self, contact, friend, resync = False):
62         """Update the given contact with information from the given friend."""
63         
64         pass
65     
66 """        
67  friends = ()
68  for service in services:
69    for friend in service.get_friends():
70      friends.add(friend)
72  all_contacts = get_contacts_as_set()
73  contacts = set()
74  updated_contacts = set()
75  for econtact in addressbook.get_all_contacts():
76    contact = Contact(addressbook, econtact)
77    contacts.add(contact)
78    for service in something.get_services_by_prioritisation():
79      if service.process_contact(contact):
80        updated_contacts.add(contact)
82  for service in something.get_services_by_prioritisation():
83    service.finalise(updated_contacts)
85  for contact in updated_contacts:
86    contact.save()
87 """

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment