code: def __create_profile_from_identities(self, identities, uuid, verbose):
          import re
          EMAIL_ADDRESS_REGEX = r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$"
          NAME_REGEX = r"^\w+\s\w+"
          name = None
          email = None
          username = None
          for identity in identities:
              if not name and identity.name:
                  m = re.match(NAME_REGEX, identity.name)
                  if m:
                      name = identity.name
              if not email and identity.email:
                  m = re.match(EMAIL_ADDRESS_REGEX, identity.email)
                  if m:
                      email = identity.email
              if not username:
                  if identity.username and identity.username != 'None':
                      username = identity.username
          if not name:
              if email:
                  name = email.split('@')[0]
              elif username:
                  name = username.split('@')[0]
              else:
                  name = None
          kw = {'name': name,
                'email': email}
          api.edit_profile(self.db, uuid, **kw)
          self.log("-- profile %s updated" % uuid, verbose)