_buffer_proxy(filename_or_buf, function, reset_fp=True, file_mode='rb', *args, **kwargs)[source]

Calls a function with an open file or file-like object as the first argument. If the file originally was a filename, the file will be opened, otherwise it will just be passed to the underlying function.

  • filename_or_buf (str, open file, or file-like object) – File to pass.

  • function – The function to call.

  • reset_fp (bool) – If True, the file pointer will be set to the initial position after the function has been called.

  • file_mode – Mode to open file in if necessary.