Client._to_file_or_data(filename, data, binary=False)[source]

Either writes data into a file if filename is given or directly returns it.

  • filename (str or file) File or object being written to. If None, a string will be returned.
  • data (str or bytes) The data being written or returned.
  • binary (bool, optional) Whether to write the data as binary or text. Defaults to binary.