def execute(self, args, cwd):
    # Build everything first
    (result, all_target_outputs) = commandutil.run_build(cwd, args)
    if not result:
      # Failed - don't copy anything
      return False

    # Delete output, if desired
    if args.clean:
      try:
        shutil.rmtree(args.output)
      except:
        pass

    # Ensure output exists
    if not os.path.isdir(args.output):
      os.makedirs(args.output)

    # Sort all outputs by path, as it makes things prettier
    all_target_outputs = list(all_target_outputs)
    all_target_outputs.sort()

    # Tracks all exists checks on link parent paths
    checked_dirs = {}

    # Copy results
    print ''
    print 'Symlinking results to %s:' % (args.output)
    skipped_links = 0
    for target_output in all_target_outputs:
      # Get path relative to root
      # This will contain the build-out/ etc
      rel_path = os.path.relpath(target_output, cwd)

      # Strip the build-*/
      # TODO(benvanik): a more reliable strip
      rel_path_parts = rel_path.split(os.sep)
      if rel_path_parts[0].startswith('build-'):
        rel_path = os.path.join(*(rel_path_parts[1:]))

      # Make output path
      deploy_path = os.path.normpath(os.path.join(args.output, rel_path))

      # Ensure directory exists
      # Ensure parent of link path exists
      deploy_dir = os.path.dirname(deploy_path)
      if not checked_dirs.get(deploy_dir, False):
        if not os.path.exists(deploy_dir):
          os.makedirs(deploy_dir)
        checked_dirs[deploy_dir] = True

      # Link!
      if not os.path.exists(deploy_path):
        print '%s -> %s' % (rel_path, deploy_path)
        os.symlink(target_output, deploy_path)
      else:
        skipped_links += 1

    if skipped_links:
      print (skipped_links) % '(%s skipped)'

    return 0 if result else 1
dataset/ETHPy150Open google/anvil-build/anvil/commands/overlay_command.py/OverlayCommand.execute/swapped operands of `%`