예제 #1
0
파일: app.py 프로젝트: halldor/Mailpile
 def add_contact(self, email, name=None, kind=None):
     contact_dir = self.data_directory('contacts', mode='w', mkdir=True)
     c = Contact()
     c.filename = os.path.join(contact_dir, c.random_uid) + '.vcf'
     c.gpg_recipient = lambda: self.get('gpg_recipient')
     c.email = email
     if name is not None: c.fn = name
     if kind is not None: c.kind = kind
     self.index_contact(c)
     return c.save()
예제 #2
0
파일: app.py 프로젝트: halldor/Mailpile
 def load_contacts(self, session):
     try:
         contact_dir = self.data_directory('contacts')
         for fn in os.listdir(contact_dir):
             try:
                 c = Contact().load(os.path.join(contact_dir, fn))
                 c.gpg_recipient = lambda: self.get('gpg_recipient')
                 self.index_contact(c)
                 session.ui.mark('Loaded %s' % c.email)
             except:
                 import traceback
                 traceback.print_exc()
                 session.ui.warning('Failed to load contact %s' % fn)
     except OSError:
         pass