def exclude_paths(root, patterns, dockerfile=None):
    if dockerfile is None:
        dockerfile = 'Dockerfile'

    exceptions = [p for p in patterns if p.startswith('!')]

    include_patterns = [p[1:] for p in exceptions]
    include_patterns += [dockerfile, '.dockerignore']

    exclude_patterns = list(set(patterns) - set(exceptions))

    paths = get_paths(root, exclude_patterns, include_patterns,
                      has_exceptions=len(exceptions) > 0)

    return set(paths).union(
        # If the Dockerfile is in a subdirectory that is excluded, get_paths
        # will not descend into it and the file will be skipped. This ensures
        # it doesn't happen.
        set([dockerfile])
        if os.path.exists(os.path.join(root, dockerfile)) else set()
    )
Given a root directory path and a list of .dockerignore patterns, return
dataset/ETHPy150Open docker/docker-py/docker/utils/utils.py/exclude_paths