parameters: (src_name, dest_name)
return_statement: return True
docstring: Copy src_name -> dest_name, but only touch dest_name
      if src_name is different from dest_name, making this a
      more build system friendly way to copy.
docstring_summary: Copy src_name -> dest_name, but only touch dest_name
      if src_name is different from dest_name, making this a
      more build system friendly way to copy.
docstring_tokens: Copy src_name - > dest_name but only touch dest_name if src_name is different from dest_name making this a more build system friendly way to copy .
function: def copy_if_different(src_name, dest_name):
      """Copy src_name -> dest_name, but only touch dest_name
      if src_name is different from dest_name, making this a
      more build system friendly way to copy."""
      src_st = os.lstat(src_name)
      if not does_file_need_update(src_name, src_st, dest_name):
          return False
  
      dest_parent = os.path.dirname(dest_name)
      if not os.path.exists(dest_parent):
          os.makedirs(dest_parent)
      if stat.S_ISLNK(src_st.st_mode):
          try:
              os.unlink(dest_name)
          except OSError as exc:
              if exc.errno != errno.ENOENT:
                  raise
          target = os.readlink(src_name)
          print("Symlinking %s -> %s" % (dest_name, target))
          os.symlink(target, dest_name)
      else:
          print("Copying %s -> %s" % (src_name, dest_name))
          shutil.copy2(src_name, dest_name)
  
      return True
function_tokens: def copy_if_different ( src_name , dest_name ) : src_st = os . lstat ( src_name ) if not does_file_need_update ( src_name , src_st , dest_name ) : return False dest_parent = os . path . dirname ( dest_name ) if not os . path . exists ( dest_parent ) : os . makedirs ( dest_parent ) if stat . S_ISLNK ( src_st . st_mode ) : try : os . unlink ( dest_name ) except OSError as exc : if exc . errno != errno . ENOENT : raise target = os . readlink ( src_name ) print ( "Symlinking %s -> %s" % ( dest_name , target ) ) os . symlink ( target , dest_name ) else : print ( "Copying %s -> %s" % ( src_name , dest_name ) ) shutil . copy2 ( src_name , dest_name ) return True