code: def rename_one(links, published, fullsrc, fulldst):
      src, src_ext = os.path.splitext(fullsrc)
      dst, dst_ext = os.path.splitext(fulldst)
  
      out = []
  
      if src in published:
          # This src was published at some point, so emit a new redirect to preserve the url.
          l = Link(src, dst)
          print(ylw + f"adding new {l}" + res, file=sys.stderr)
          out.append(Link(src, dst))
      else:
          # This src was never published and we don't care about it.
          print(
              ylw
              + f"omitting new redirect for unpublished url {src}"
              + res,
              file=sys.stderr,
          )
  
      # Update existing links that may be affected.
      for l in links:
          if l.src == src:
              # This should not happen; we have checks to prevent links shadowing real files.
              raise RuntimeError(
                  "detected link shadowing existing file in rename()"
              )
          if l.src == dst:
              # The new filename shadows an old redirect, which we should just drop.
              print(
                  ylw
                  + f"dropping {l} which would shadow dst={dst}"
                  + res,
                  file=sys.stderr,
              )
              continue
          if l.dst == src:
              # Link used to point to this file, now it should point to the new location.
              print(
                  ylw + f"correcting {l} to point to dst={dst}" + res,
                  file=sys.stderr,
              )
              out.append(Link(l.src, dst))
              continue
          if l.dst == dst:
              # The old link is probably not pointing to the right thing anymore.
              print(
                  red + f"Old {l} may not make sense anymore" + res,
                  file=sys.stderr,
              )
          # Leave link unmodified.
          out.append(l)
      return out
  
file_path: determined/docs/redirects.py
imports: import argparse
  import collections
  import itertools
  import json
  import os
  import pathlib
  import subprocess
  import sys
label_desc: Use image node_id 4 for calling a global function with example usage: rename_one(links, published, fullsrc, fulldst) and returns: out