本文整理汇总了Python中contact.Contact类的典型用法代码示例。如果您正苦于以下问题:Python Contact类的具体用法?Python Contact怎么用?Python Contact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Contact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__ (self, folder, con=None, vco=None, itemid=None):
"""vco, if not None, should be a valid vCard object (i.e. the contents
of a vCard file, for e.g. When vco is not None, itemid should also be
not None"""
Contact.__init__(self, folder, con)
self.set_etag(None)
self.set_uid(None)
self.set_vco(vco)
self._group_count = 0
## Sometimes we might be creating a contact object from a Google
## contact object or other entry which might have the ID in its sync
## tags field. if that is present, we should use it to initialize the
## itemid field for the current object
conf = self.get_config()
if con:
try:
pname_re = conf.get_profile_name_re()
label = conf.make_sync_label(pname_re, self.get_dbid())
tag, itemid = con.get_sync_tags(label)[0]
self.set_itemid(itemid)
except Exception, e:
logging.debug('Potential new CDContact: %s', con.get_name())
示例2: __init__
def __init__ (self, folder, olprops=None, eid=None, con=None):
"""Constructor for OLContact. The starting properties of the contact
can be initialized either from an existing Contact object, or from an
Outlook item property list. It is an error to provide both.
It is redundant to provide both olprops (array of property tuples) and
an entryid. The entryid will override the property list.
"""
if ((olprops and con) or (eid and con)):
raise OLContactError(
'Both olprops/eid and con cannot be specified in OLContact()')
if olprops and eid:
logging.warning('olprops and eid are not null. Ignoring olprops')
olprops = None
Contact.__init__(self, folder, con)
## Sometimes we might be creating a contact object from GC or other
## entry which might have the Entry ID in its sync tags
## field. if that is present, we should use it to initialize the
## itemid field for the current object
conf = self.get_config()
if con:
try:
pname_re = conf.get_profile_name_re()
label = conf.make_sync_label(pname_re, self.get_dbid())
tag, itemid = con.get_sync_tags(label)[0]
self.set_entryid(base64.b64decode(itemid))
except Exception, e:
logging.debug('Potential new OLContact: %s', con.get_name())
示例3: __init__
def __init__ (self, folder, con=None, con_itemid=None, rec=None):
"""rec is the native string vector representation of a BBDB contact
entry on disk."""
Contact.__init__(self, folder, con)
self.atts.update({'bbdb_folder' : None,})
conf = self.get_config()
if con:
if con_itemid:
self.set_itemid(con_itemid)
else:
logging.debug('Potential new BBContact: %s', con.get_name())
if folder.get_name():
self.set_bbdb_folder(folder.get_name())
if rec:
self.set_rec(rec)
self.init_props_from_rec(rec)
if not self.get_itemid():
iid = ('%s' % uuid.uuid1())
logging.debug('Assigning UUID %s for new contact: %s', iid,
self.get_name())
self.set_itemid(iid)
self.in_init(False)
示例4: __init__
def __init__ (self, folder, con=None, rec=None):
"""rec is the native string vector representation of a BBDB contact
entry on disk."""
Contact.__init__(self, folder, con)
self.atts.update({'bbdb_folder' : None,})
## Sometimes we might be creating a contact object from a Google
## contact object or other entry which might have the ID in its sync
## tags field. if that is present, we should use it to initialize the
## itemid field for the current object
conf = self.get_config()
if con:
try:
pname_re = conf.get_profile_name_re()
label = conf.make_sync_label(pname_re, self.get_dbid())
tag, itemid = con.get_sync_tags(label)[0]
self.set_itemid(itemid)
except Exception, e:
logging.debug('Potential new BBContact: %s', con.get_name())
if folder.get_name():
self.set_bbdb_folder(folder.get_name())
示例5: __init__
def __init__ (self, folder, con=None, con_itemid=None, vco=None, itemid=None,
debug_vcf=False):
"""vco, if not None, should be a valid vCard object (i.e. the contents
of a vCard file, for e.g. When vco is not None, itemid should also be
not None"""
Contact.__init__(self, folder, con)
self.debug_vcf = debug_vcf
self.set_etag(None)
self.set_uid(None)
self.set_vco(vco)
self._group_count = 0
conf = self.get_config()
if con:
if con_itemid:
self.set_itemid(self.normalize_cdid(con_itemid))
else:
logging.debug('Potential new CDContact: %s', con.get_name())
elif vco:
self.init_props_from_vco(vco)
if not self.debug_vcf:
assert(itemid)
self.set_itemid(itemid)
self.in_init(False)
if not self.get_uid():
self.set_uid(str(uuid.uuid1()))
示例6: __init__
def __init__ (self, folder, ews_con=None, con=None):
"""Constructor for EXContact. The starting properties of the contact
can be initialized either from an existing Contact object, or from an
pyews contact object. It is an error to provide both.
"""
if (ews_con and con):
raise EXContactError(
'Both ews con and con cannot be specified in EXContact()')
Contact.__init__(self, folder, con)
## Sometimes we might be creating a contact object from a remote
## source which might have the Entry ID in its sync tags field. if
## that is present, we should use it to initialize the itemid field
## for the current object
conf = self.get_config()
if con:
try:
pname_re = conf.get_profile_name_re()
label = conf.make_sync_label(pname_re, self.get_dbid())
tag, itemid = con.get_sync_tags(label)[0]
self.set_itemid(itemid)
except Exception, e:
logging.debug('Potential new EXContact: %s', con.get_disp_name())
示例7: extract_contact
def extract_contact(self):
if not self.type_in(c.IPMSG_BR_ENTRY, c.IPMSG_ANSENTRY):
contact = Contact(name=self.name, group='', host=self.host, addr=self.addr, login=self.name)
contact.temporary = True
else:
contact = Contact(name=self.msg, group=self.group, host=self.host, addr=self.addr, login=self.name)
contact.encrypt_opt = self.test(c.IPMSG_ENCRYPTOPT)
return contact
示例8: main
def main():
bd = GestionBD(BaseMySQL.dbName, BaseMySQL.user,
BaseMySQL.passwd, BaseMySQL.host)
if bd.echec:
sys.exit()
while 1:
print "\nQue voulez-vous faire :\n"\
"1) Créer les tables de la base de données\n"\
"2) Supprimer les tables de la base de données ?\n"\
"3) Entrer des employés\n"\
"4) Lister des employés\n"\
"5) Exécuter une requête SQL quelconque\n"\
"6) Enregister sous format ldif\n"\
"7) Terminer ? Votre choix :",
ch = int(raw_input())
if ch == 1:
# Create all the tables described in the thesaurus
bd.creerTables(BaseMySQL.dicoT)
elif ch == 2:
# Drop all the tables described in the thesaurus
bd.supprimerTables(BaseMySQL.dicoT)
elif ch == 3:
# Integration of employees
table = {3: 'employes'}[ch]
enreg = Sauvegarde(bd, table)
while 1:
if enreg.save():
break
elif ch == 4:
# List of all employees
table = {4: 'employes'}[ch]
if bd.executerReq("SELECT * FROM %s" % table):
records = bd.resultatReq()
for rec in records:
for item in rec:
print item,
print
elif ch == 5:
# Any query
req = raw_input("Enter SQL query : ")
if bd.executerReq(req):
print bd.resultatReq()
elif ch == 6:
# Save
fic = raw_input('Enter filename to process: ')
ofi = open(fic, "w")
contact = Contact()
table = {6: 'employes'}[ch]
if bd.executerReq("SELECT * FROM %s" % table):
records = bd.resultatReq()
for rec in records:
contact = Contact(*rec[1:])
ofi.write(contact.get_contact_ldif())
ofi.close()
else:
bd.commit()
bd.close()
break
示例9: testDeleteContactById
def testDeleteContactById(self):
contactId = 1
#check if contact #1 exist
contact = Contact.retrieve(contactId)
self.failUnless(contact)
#delete contact #1
successful = contact.delete()
self.failUnless(successful)
#confirm contact #1 no longer exist
contact = Contact.retrieve(contactId)
self.failIf( contact )
示例10: __init__
def __init__(self, prompt=":> ", quitChar='\\'):
self.prompt = prompt
self.quitChar = quitChar
self.mainMenu = """
{} Exit Prompt
1 Create Contact
2 Edit Contact
3 Delete Contact
4 Show Contact
@Main{}""".format(quitChar, prompt )
contactDb = ContactsDb('localhost', 'root', '1234', 'contacts_orm', 'contacts' )
Contact.connect(contactDb)
pass
示例11: new_contact
def new_contact(self, token, name, surname):
"""
Create new contact
:param token: which returned by user login
:param name: Name of the new contact
:param surname: Surname of the new Contact
:return:
"""
user = User.get_by_id(token.userid)
if not user:
return errors.UserDoesNotFound()
Contact.new_contact(user._id, name, surname)
return {}
示例12: showContactPrompt
def showContactPrompt(self):
shower = ShowContactPrompt(self.prompt)
id = shower.readContactIdToShow()
if id == -1:
contacts = Contact.retrieveAll()
shower.showAll(contacts)
return
contact = Contact.retrieve(id)
if contact:
shower.show(contact)
else:
print 'Contact #{} does not exist'.format(id)
shower.readContactIdToShow()
示例13: __init__
def __init__(self, folder, con=None, con_itemid=None, gce=None):
Contact.__init__(self, folder, con)
conf = self.get_config()
if con:
if con_itemid:
self.set_itemid(self.normalize_gcid(con_itemid))
else:
logging.debug("Potential new GCContact: %s", con.get_disp_name())
self.set_gce(gce)
if gce:
self.init_props_from_gce(gce)
self.in_init(False)
示例14: got_forward_message
def got_forward_message(self, contact, obj):
self.forward(
key=obj.key,
message=obj.message,
raw_key=obj.raw_key,
requester=Contact.from_tuple(obj.requester, self)
)
示例15: __initialization
def __initialization(self, data):
if data is None:
raise Exception("Data is invalid")
self.firstname = data.get('firstname', None)
self.lastname = data.get(u'lastname', None)
self.birthdate = data.get('birthdate', None)
birthplace = data.get('birthplace', None)
if birthplace is not None:
self.birthplace = Place(birthplace)
employers = data.get('work_experience', [])
if isinstance(employers, list):
for employer in employers:
self.work_experience.append(
Employer(employer)
)
degrees = data.get('education', [])
if isinstance(degrees, list):
for degree in degrees:
self.education.append(Degree(degree))
contacts = data.get('contacts', [])
if isinstance(contacts, list):
for contact in contacts:
self.contacts.append(Contact.get_instance(contact))