original_docstring: 
      For each target fstat on stdin, copy the matching file from the
      seed directory if 1) the seed fstat agrees, or 2) if no fstat, the
      checksum agrees. Output the fstat entries that were not copied.
      
docstring: For each target fstat on stdin, copy the matching file from the
  seed directory if 1) the seed fstat agrees, or 2) if no fstat, the
  checksum agrees. Output the fstat entries that were not copied.
docstring_tokens: For each target fstat on stdin copy the matching file from the seed directory if 1 ) the seed fstat agrees or 2 ) if no fstat the checksum agrees . Output the fstat entries that were not copied .
code: def o4_seed_from(seed_dir, seed_fstat, op):
      """
      For each target fstat on stdin, copy the matching file from the
      seed directory if 1) the seed fstat agrees, or 2) if no fstat, the
      checksum agrees. Output the fstat entries that were not copied.
      """
  
      def no_uchg(*fnames):
          check_call(['chflags', 'nouchg'] + [fname for fname in fnames if os.path.exists(fname)])
  
      def update_target(src, dest, fsop):
          try:
              try:
                  os.makedirs(os.path.dirname(dest), exist_ok=True)
                  fsop(src, dest)
              except IOError as e:
                  if e.errno == EPERM and sys.platform == 'darwin':
                      no_uchg(src, dest)
                      fsop(src, dest)
                  else:
                      raise
          except IOError as e:
              print(f'# ERROR MOVING {src}: {e!r}')
  
      fsop = shutil.move if op == 'move' else partial(shutil.copy2, follow_symlinks=False)
  
      seed_checksum = None
      if seed_fstat:
          seed_checksum = {
              f[F_PATH]: f[F_CHECKSUM] for f in fstat_from_csv(seed_fstat, fstat_split) if f
          }
      target_dir = os.getcwd()
      with chdir(seed_dir):
          for line in sys.stdin:
              if line.startswith('#o4pass'):
                  print(line, end='')
                  continue
              f = fstat_split(line)
              if not f:
                  continue
              if f[F_CHECKSUM]:
                  dest = os.path.join(target_dir, f[F_PATH])
                  if os.path.lexists(dest):
                      try:
                          os.unlink(dest)
                      except IOError as e:
                          if e.errno == EPERM and sys.platform == 'darwin':
                              no_uchg(dest)
                              os.unlink(dest)
                          else:
                              raise
                  if f[F_FILE_SIZE].endswith('symlink'):
                      update_target(f[F_PATH], dest, fsop)
                      continue
                  if seed_fstat:
                      checksum = seed_checksum.get(f[F_PATH])
                  else:
                      checksum = Pyforce.checksum(f[F_PATH], f[F_FILE_SIZE])
                  if checksum == f[F_CHECKSUM]:
                      update_target(f[F_PATH], dest, fsop)
                      continue
              print(line, end='')
code_tokens: def o4_seed_from ( seed_dir , seed_fstat , op ) : def no_uchg ( * fnames ) : check_call ( [ 'chflags' , 'nouchg' ] + [ fname for fname in fnames if os . path . exists ( fname ) ] ) def update_target ( src , dest , fsop ) : try : try : os . makedirs ( os . path . dirname ( dest ) , exist_ok = True ) fsop ( src , dest ) except IOError as e : if e . errno == EPERM and sys . platform == 'darwin' : no_uchg ( src , dest ) fsop ( src , dest ) else : raise except IOError as e : print ( f'# ERROR MOVING {src}: {e!r}' ) fsop = shutil . move if op == 'move' else partial ( shutil . copy2 , follow_symlinks = False ) seed_checksum = None if seed_fstat : seed_checksum = { f [ F_PATH ] : f [ F_CHECKSUM ] for f in fstat_from_csv ( seed_fstat , fstat_split ) if f } target_dir = os . getcwd ( ) with chdir ( seed_dir ) : for line in sys . stdin : if line . startswith ( '#o4pass' ) : print ( line , end = '' ) continue f = fstat_split ( line ) if not f : continue if f [ F_CHECKSUM ] : dest = os . path . join ( target_dir , f [ F_PATH ] ) if os . path . lexists ( dest ) : try : os . unlink ( dest ) except IOError as e : if e . errno == EPERM and sys . platform == 'darwin' : no_uchg ( dest ) os . unlink ( dest ) else : raise if f [ F_FILE_SIZE ] . endswith ( 'symlink' ) : update_target ( f [ F_PATH ] , dest , fsop ) continue if seed_fstat : checksum = seed_checksum . get ( f [ F_PATH ] ) else : checksum = Pyforce . checksum ( f [ F_PATH ] , f [ F_FILE_SIZE ] ) if checksum == f [ F_CHECKSUM ] : update_target ( f [ F_PATH ] , dest , fsop ) continue print ( line , end = '' )
short_docstring: For each target fstat on stdin, copy the matching file from the
  seed directory if 1) the seed fstat agrees, or 2) if no fstat, the
  checksum agrees.
short_docstring_tokens: For each target fstat on stdin copy the matching file from the seed directory if 1 ) the seed fstat agrees or 2 ) if no fstat the checksum agrees .
comment: """
      For each target fstat on stdin, copy the matching file from the
      seed directory if 1) the seed fstat agrees, or 2) if no fstat, the
      checksum agrees. Output the fstat entries that were not copied.
      """