docs: def sync_from_log(src, dst, log_file, exclude=()):
      """
      Sync the files in ``src`` to ``dst``.
  
      The files that are synced are logged to ``log_file``. If ``log_file``
      exists, the files in ``log_file`` are removed first.
  
      Returns ``(added, removed)``, where added is a list of all files synced from
      ``src`` (even if it already existed in ``dst``), and ``removed`` is every
      file from ``log_file`` that was removed from ``dst`` because it wasn't in
      ``src``. ``added`` also includes the log file.
  
      ``exclude`` may be a list of paths from ``src`` that should be ignored.
      Such paths are neither added nor removed, even if they are in the logfile.
      """
      from os.path import join, exists, isdir
  
      exclude = [os.path.normpath(i) for i in exclude]
  
      added, removed = [], []
  
      if not exists(log_file):
          # Assume this is the first run
          print("%s doesn't exist. Not removing any files." % log_file)
      else:
          with open(log_file) as f:
              files = f.read().strip().split('\n')
  
          for new_f in files:
              new_f = new_f.strip()
              if any(is_subdir(new_f, os.path.join(dst, i)) for i in exclude):
                  pass
              elif exists(new_f):
                  os.remove(new_f)
                  removed.append(new_f)
              else:
                  print("Warning: File %s doesn't exist." % new_f, file=sys.stderr)
  
      if os.path.isdir(src):
          if not src.endswith(os.sep):
              src += os.sep
          files = glob.iglob(join(src, '**'), recursive=True)
      else:
          files = [src]
          src = os.path.dirname(src) + os.sep if os.sep in src else ''
  
          os.makedirs(dst, exist_ok=True)
  
      # sorted makes this easier to test
      for f in sorted(files):
          if any(is_subdir(f, os.path.join(src, i)) for i in exclude):
              continue
          new_f = join(dst, f[len(src):])
  
          if isdir(f) or f.endswith(os.sep):
              os.makedirs(new_f, exist_ok=True)
          else:
              shutil.copy2(f, new_f)
              added.append(new_f)
              if new_f in removed:
                  removed.remove(new_f)
  
      with open(log_file, 'w') as f:
          f.write('\n'.join(added))
  
      added.append(log_file)
  
      return added, removed