def _does_id_match()

in tools/plisttool/plisttool.py [0:0]


  def _does_id_match(self,
                     id,
                     allowed,
                     allowed_supports_wildcards=False,
                     id_supports_wildcards=False):
    """Check is an id matches the given allowed id (include wildcards).

    Args:
      id: The identifier to check.
      allowed: The allowed identifier which can end in a wildcard.
      allowed_supports_wildcards: True/False for if wildcards should
          be supported in the `allowed` value.
      id_supports_wildcards: True/False for if a wildcard should be
          allowed/supported in the input id. This is very rare.
    Returns:
      True/False if the identifier is covered.
    """
    if allowed_supports_wildcards and allowed.endswith('*'):
      if id.startswith(allowed[:-1]):
        return True
    else:
      if id == allowed:
        return True

    # Since entitlements files can use wildcards, the file a developer
    # makes could have a wildcard and the value within the profile could
    # also have a wildcard. The substitutions done normally remove the
    # wildcard in the processed entitlements file, but just in case it
    # doesn't, validate that the two agree.
    if id_supports_wildcards and id.endswith('*'):
      if allowed.endswith('*'):
        if id[:-1].startswith(allowed[:-1]):
          return True
      else:
        if allowed.startswith(id[:-1]):
          return True

    return False