Exemple #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)
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 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()
Exemple #5
0
 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()
Exemple #6
0
 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()
 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