def METHOD_NAME(source, parent_dir, target=None):
    """Copy `source` to `parent_dir`, optionally renaming.
    Args:
        source (str): the source path
        parent_dir (str): the target parent dir. This doesn't have to exist
        target (str, optional): the basename of the target file.  If None,
            use the basename of `source`. Defaults to None.
    Raises:
        SigningServerError: on failure
    """
    target = target or os.path.basename(source)
    target_path = os.path.join(parent_dir, target)
    try:
        parent_dir = os.path.dirname(target_path)
        mkdir(parent_dir)
        if source != target_path:
            log.info("Copying %s to %s" % (source, target_path))
            copyfile(source, target_path)
            return target_path
        else:
            log.info("Not copying %s to itself" % (source))
    except (IOError, OSError):
        log.exception("Can't copy %s to %s!", source, target_path)
        raise SigningServerError("Can't copy {} to {}!".format(source, target_path))