@gen.coroutine
def UploadContacts(client, obj_store, user_id, device_id, request):
 request['user_id'] = user_id
 contact_count = len(request['contacts'])
 result_contact_ids = []
 for contact in request['contacts']:
  canon_identities = set()
  identities_properties = []
  for contact_identity in contact['identities']:
   identity_key = contact_identity['identity']
   description = contact_identity.get('description', None)
   if (identity_key != Identity.Canonicalize(identity_key)):
    raise InvalidRequestError(IDENTITY_NOT_CANONICAL, identity_key=identity_key)
   canon_identities.add(identity_key)
   identities_properties.append((identity_key, description))
  contact['identities'] = list(canon_identities)
  contact['identities_properties'] = identities_properties
  contact['contact_id'] = Contact.CalculateContactId(contact)
  result_contact_ids.append(contact['contact_id'])
 (yield gen.Task(Operation.CreateAndExecute, client, user_id, device_id, 'UploadContactsOperation.Execute', request))
 logging.info(('UPLOAD CONTACTS: user: %d, device: %d, contact_count: %d' % (user_id, device_id, contact_count)))
 raise gen.Return({'contact_ids': result_contact_ids})

@ gen . coroutine def UploadContacts ( client , obj_store , user_id , device_id , request ) : request [ 'user_id' ] = user_id contact_count = len ( request [ 'contacts' ] ) result_contact_ids = [ ] for contact in request [ 'contacts' ] : canon_identities = set ( ) identities_properties = [ ] for contact_identity in contact [ 'identities' ] : identity_key = contact_identity [ 'identity' ] description = contact_identity . get ( 'description' , None ) if ( identity_key != Identity . Canonicalize ( identity_key ) ) : raise InvalidRequestError ( IDENTITY_NOT_CANONICAL , identity_key = identity_key ) canon_identities . add ( identity_key ) identities_properties . append ( ( identity_key , description ) ) contact [ 'identities' ] = list ( canon_identities ) contact [ 'identities_properties' ] = identities_properties contact [ 'contact_id' ] = Contact . CalculateContactId ( contact ) result_contact_ids . append ( contact [ 'contact_id' ] ) ( yield gen . Task ( Operation . CreateAndExecute , client , user_id , device_id , 'UploadContactsOperation.Execute' , request ) ) logging . info ( ( 'UPLOAD CONTACTS: user: %d, device: %d, contact_count: %d' % ( user_id , device_id , contact_count ) ) ) raise gen . Return ( { 'contact_ids' : result_contact_ids } )
creates/updates contacts metadata .