<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cp(src, dst):
 """ Copy a file or directory. If source is a directory, this recursively copies the directory and its contents. If the destination is a directory, then this creates a copy of the source in the destination directory with the same basename. If the destination already exists, this will attempt to overwrite it. Arguments: src (string):
 path to the source file or directory. dst (string):
 path to the destination file or directory. Raises: IOError: if source does not exist. """

    if isdir(src):
        # Overwrite an existing directory.
        if isdir(dst):
            rm(dst)
        shutil.copytree(src, dst)
    elif isfile(src):
        shutil.copy(src, dst)
    else:
        raise IOError("Source '{0}' not found".format(src))