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((set([dockerfile]) if os.path.exists(os.path.join(root, dockerfile)) else set()))

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 ( ( set ( [ dockerfile ] ) if os . path . exists ( os . path . join ( root , dockerfile ) ) else set ( ) ) )
given a root directory path and a list of .