code: def preclean(bazel_aquery):
      """Cleans up any genrule() outputs for the provided target(s).
  
      This is useful for forcing genrule actions to re-run, because the _true_
      outputs of those actions can include a larger set of files (e.g. files
      copied to the workspace) which Bazel is unable to detect changes to (or
      delete changes of).
  
      Usually, you would run this script along with 'git clean -f', to make sure
      Bazel re-copies outputs the next time a build occurs.
      """
      result = 0
      bazel = Bazel()
      aquery_results = bazel.aquery(
          "--include_artifacts=true", bazel_aquery
      )
      for path in parse_aquery_output_artifacts(aquery_results):
          try:
              if sys.platform == "win32":
                  os.chmod(
                      path, stat.S_IWRITE
                  )  # Needed to remove read-only bit
              os.remove(path)
          except IOError as ex:
              if ex.errno != errno.ENOENT:
                  sys.stderr.write(str(ex) + "\n")
                  result = result or ex.errno
      return result
  
imports: import ast
  import errno
  import json
  import os
  import re
  import subprocess
  import stat
  import sys
  from collections import defaultdict, OrderedDict
label_desc: Use image node_id 7 for calling a global function with example usage: preclean(bazel_aquery) and returns: result