code: def string_to_identity(identity_str):
      
      m = _identity_regexp.match(identity_str)
      result = m.groupdict()
      log.debug('parsed identity: %s', result)
      return {k: v for k, v in result.items() if v}
docs: Parse string into Identity dictionary.