def dump(self, f):
        """
        Dump data to a file.

        :param f: file-like object or path to file
        :type f: file or str
        """
        self.validate()
        with _open_file_obj(f, "w") as f:
            parser = self._get_parser()
            self.serialize(parser)
            self.build_file(parser, f)
Dump data to a file.

        :param f: file-like object or path to file
        :type f: file or str