def __call__()

in src/aws_encryption_sdk_cli/internal/metadata.py [0:0]


    def __call__(self, output_file=None):
        # type: (Optional[str]) -> MetadataWriter
        """Set the output file target and validate init and call arguments.

        .. note::
            Separated from ``__init__`` to make use as an argparse type simpler.

        :param str output_file: Path to file to write to, or "-" for stdout (optional)
        """
        self.output_file = output_file

        if self.suppress_output:
            return self

        if self.output_file is None:
            raise TypeError("output_file cannot be None when suppress_output is False")

        if self.output_file == "-":
            self._output_mode = "w"
            return self

        if not os.path.isdir(os.path.dirname(os.path.realpath(self.output_file))):
            raise BadUserArgumentError("Parent directory for requested metdata file does not exist.")

        self._output_mode = "ab"
        self.output_file = os.path.abspath(self.output_file)

        attr.validate(self)

        return self