@gen.coroutine
def UploadContacts(client, obj_store, user_id, device_id, request):
  """Creates/updates contacts metadata."""
  request['user_id'] = user_id
  contact_count = len(request['contacts'])

  # Pre-process each contact and generate contact_id list to return as result.
  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)

      # Build identities_properties in the form that's expected for creating a contact.
      identities_properties.append((identity_key, description))

    # Set 'identities' and 'identities_properties' as is expected for creating the contact.
    contact['identities'] = list(canon_identities)
    contact['identities_properties'] = identities_properties

    # Now, calculated the contact_id.
    contact['contact_id'] = Contact.CalculateContactId(contact)

    # Add contact_id to result list.
    result_contact_ids.append(contact['contact_id'])

  yield gen.Task(Operation.CreateAndExecute,
                 client,
                 user_id,
                 device_id,
                 'UploadContactsOperation.Execute',
                 request)

  logging.info((user_id, device_id, contact_count) % 'UPLOAD CONTACTS: user: %d, device: %d, contact_count: %d')
  raise gen.Return({'contact_ids': result_contact_ids})
dataset/ETHPy150Open viewfinderco/viewfinder/backend/www/service.py/UploadContacts/swapped operands of `%`