def _catch_bad_file_and_directory_requests()

in src/aws_encryption_sdk_cli/__init__.py [0:0]


def _catch_bad_file_and_directory_requests(expanded_sources, destination):
    # type: (List[str], str) -> None
    """Catches bad requests based on characteristics of source and destination when
    source contains files or directories.

    :param list expanded_sources: List of source paths
    :param str destination: Identifier for the destination (filesystem path or ``-`` for stdout)
    :raises BadUserArgumentError: if source contains multiple files and destination is not an existing directory
    :raises BadUserArgumentError: if source contains a directory and destination is not an existing directory
    """
    if len(expanded_sources) > 1 and not os.path.isdir(destination):
        raise BadUserArgumentError("If operating on multiple sources, destination must be an existing directory")

    for _source in expanded_sources:
        if os.path.isdir(_source):
            if not os.path.isdir(destination):
                raise BadUserArgumentError(
                    "If operating on a source directory, destination must be an existing directory"
                )