parameters: (root, exclude_dirs, exclude_files)
docstring: Remove anything in either of the blacklists, then remove all empty
      directories under root and its children
docstring_summary: Remove anything in either of the blacklists, then remove all empty
      directories under root and its children
docstring_tokens: Remove anything in either of the blacklists then remove all empty directories under root and its children
function: def _clean_dir(root, exclude_dirs, exclude_files):
      """
      Remove anything in either of the blacklists, then remove all empty
      directories under root and its children
      """
      exclude_files = [os.path.normpath(os.path.join(root, f)) for f in exclude_files ]
      exclude_dirs = [os.path.normpath(os.path.join(root, d)) for d in exclude_dirs ]
  
      # first pass, remove blacklisted files
      for base, dirs, files in os.walk(root, topdown=True):
          if base in exclude_dirs:
              shutil.rmtree(base)
              continue
          
          for file in files:
              absfile = os.path.abspath(os.path.join(base, file))
              if absfile in exclude_files and os.path.isfile(absfile):
                  os.unlink(absfile)
  
      # second pass, remove empty dirs
      for base, dirs, files in os.walk(root, topdown=True):
          if not dirs and not files:
              os.rmdir(base)
function_tokens: def _clean_dir ( root , exclude_dirs , exclude_files ) : exclude_files = [ os . path . normpath ( os . path . join ( root , f ) ) for f in exclude_files ] exclude_dirs = [ os . path . normpath ( os . path . join ( root , d ) ) for d in exclude_dirs ] # first pass, remove blacklisted files for base , dirs , files in os . walk ( root , topdown = True ) : if base in exclude_dirs : shutil . rmtree ( base ) continue for file in files : absfile = os . path . abspath ( os . path . join ( base , file ) ) if absfile in exclude_files and os . path . isfile ( absfile ) : os . unlink ( absfile ) # second pass, remove empty dirs for base , dirs , files in os . walk ( root , topdown = True ) : if not dirs and not files : os . rmdir ( base )