docs: def _cleanup(self, dry_run=False):
          """
          Cleans up (removes) intermediate files.
  
          You can register intermediate files, which will be deleted automatically
          when the pipeline completes. This function deletes them,
          either absolutely or conditionally. It is run automatically when the
          pipeline succeeds, so you shouldn't need to call it from a pipeline.
  
          :param bool dry_run: Set to True if you want to build a cleanup
              script, but not actually delete the files.
          """
  
          if dry_run:
              # Move all unconditional cleans into the conditional list
              if len(self.cleanup_list) > 0:
                  combined_list = self.cleanup_list_conditional + self.cleanup_list
                  self.cleanup_list_conditional = combined_list
                  self.cleanup_list = []
  
          if len(self.cleanup_list) > 0:
              print("\nCleaning up flagged intermediate files. . .")
              for expr in self.cleanup_list:
                  print("\nRemoving glob: " + expr)
                  try:
                      # Expand regular expression
                      files = glob.glob(expr)
                      # Remove entry from cleanup list
                      while files in self.cleanup_list:
                          self.cleanup_list.remove(files)
                      # and delete the files
                      for file in files:
                          if os.path.isfile(file):
                              print("`rm " + file + "`")
                              os.remove(os.path.join(file))
                          elif os.path.isdir(file):
                              print("`rmdir " + file + "`")
                              os.rmdir(os.path.join(file))
                  except:
                      pass
  
          if len(self.cleanup_list_conditional) > 0:
              run_flag = flag_name(RUN_FLAG)
              flag_files = [fn for fn in glob.glob(self.outfolder + flag_name("*"))
                            if COMPLETE_FLAG not in os.path.basename(fn)
                            and not "{}_{}".format(self.name, run_flag) == os.path.basename(fn)]
              if len(flag_files) == 0 and not dry_run:
                  print("\nCleaning up conditional list. . .")
                  for expr in self.cleanup_list_conditional:
                      print("\nRemoving glob: " + expr)
                      try:
                          files = glob.glob(expr)
                          while files in self.cleanup_list_conditional:
                              self.cleanup_list_conditional.remove(files)
                          for file in files:
                              if os.path.isfile(file):
                                  print("`rm " + file + "`")
                                  os.remove(os.path.join(file))
                              elif os.path.isdir(file):
                                  print("`rmdir " + file + "`")
                                  os.rmdir(os.path.join(file))
                      except:
                          pass
              else:
                  print("\nConditional flag found: " + str([os.path.basename(i) for i in flag_files]))
                  print("\nThese conditional files were left in place:\n\n- " + "\n- ".join(self.cleanup_list_conditional))
                  # Produce a cleanup script.
                  no_cleanup_script = []
                  for cleandir in self.cleanup_list_conditional:
                      try:
                          items_to_clean = glob.glob(cleandir)
                          for clean_item in items_to_clean:
                              with open(self.cleanup_file, "a") as clean_script:
                                  if os.path.isfile(clean_item):
                                      clean_script.write("rm " + clean_item + "\n")
                                  elif os.path.isdir(clean_item):
                                      clean_script.write("rmdir " + clean_item + "\n")
                      except Exception as e:
                          no_cleanup_script.append(cleandir)
                  if no_cleanup_script: 
                      print('\n\nCould not produce cleanup script for item(s):\n\n- ' + '\n- '.join(no_cleanup_script))