import fnmatch


def filter_modules(modpaths, patterns):
    """filter away modules that match a specific name pattern.
    Note: since modpaths are full filepaths, the name pattern
    MUST be specified for the path itself, as opposed to only
    the filename.

    Args:
        modpaths (List[str]): list of absolute modules filepath to
          filter
        patterns (List[str]): list of strings with Unix shell-style
          wildcards.
    Returns:
        List[str]: list of absolute filepaths that didnt match
          any pattern.
    """
    for pattern in patterns:
        modpaths = [ filepath for filepath in modpaths
                     if not fnmatch.fnmatch(filepath, pattern) ]
    return modpaths