import re


def _gridset_matches_platform(gridset, pattern, platform):
    """Returns True if the given gridset contains any files matching the given platform.

    gridset: gridset with metadata; the metadata has a list of files (no nested
             lists)

    pattern: regex matching file names in gridset['metadata']['files'], with a
             "platform" capture group

    platform: the platform to match

    """
    for file_ in gridset['metadata']['files']:
        match = re.match(pattern, file_)
        if match.group('platform') == platform:
            return True
    return False