from pathlib import Path
import shutil


def copy_file_to_target(source_file: Path, destination_directory: Path) -> bool:
    """

    Args:
        source_file: a file to copy
        destination_directory: the directory to copy source_file into

    Returns: True if copy was successful, False otherwise

    """
    if source_file.exists() and source_file.is_file():
        print("Found file at %s" % source_file.resolve())
    else:
        print("Unable to find required file, looked at %s" % source_file.resolve())
        return False
    if not destination_directory.exists():
        destination_directory.mkdir(parents=True, mode=0o777)
    destination_filepath = destination_directory / source_file.name
    if destination_filepath.exists():
        if input(f"Found file at ({destination_filepath}). This is likely hanging around from a previous install. OK to "
                 f"delete this file? (y/N)") == 'y':
            destination_filepath.unlink()
        else:
            return False
    print("Copying to file at path %s" % destination_filepath)
    shutil.copyfile(str(source_file), str(destination_filepath))
    return True