示例#1
0
 def _make_new_vcard(self, handle, name):
     l = [VCardLine(name='fn', value=name),
          VCardLine(name='kind', value=self.KIND)]
     if self.KIND == 'individual':
         return SimpleVCard(VCardLine(name='email', value=handle), *l)
     else:
         return SimpleVCard(VCardLine(name='nickname', value=handle), *l)
示例#2
0
文件: app.py 项目: zouxc-zz/Mailpile
 def add_vcard(self, handle, name=None, kind=None):
     vcard_dir = self.data_directory('vcards', mode='w', mkdir=True)
     c = SimpleVCard()
     c.filename = os.path.join(vcard_dir, c.random_uid) + '.vcf'
     c.gpg_recipient = lambda: self.get('gpg_recipient')
     if kind == 'individual':
         c.email = handle
     else:
         c['NICKNAME'] = handle
     if name is not None: c.fn = name
     if kind is not None: c.kind = kind
     self.index_vcard(c)
     return c.save()
示例#3
0
文件: app.py 项目: zouxc-zz/Mailpile
 def load_vcards(self, session):
     try:
         vcard_dir = self.data_directory('vcards')
         for fn in os.listdir(vcard_dir):
             try:
                 c = SimpleVCard().load(os.path.join(vcard_dir, fn))
                 c.gpg_recipient = lambda: self.get('gpg_recipient')
                 self.index_vcard(c)
                 session.ui.mark('Loaded %s' % c.email)
             except:
                 import traceback
                 traceback.print_exc()
                 session.ui.warning('Failed to load vcard %s' % fn)
     except OSError:
         pass
示例#4
0
 def _add_vcard(self, full_name, email):
     card = SimpleVCard(VCardLine(name='fn', value=full_name),
                        VCardLine(name='email', value=email))
     self.config.vcards.index_vcard(card)
     return card