Skip to main content
`Ctrl`+`K`

# UnifiedReadWrite

class astropy.io.registry.UnifiedReadWrite(instance, cls, method_name, registry=None)

  Bases: `object`

  Base class for the worker object used in unified read() or write() methods.

  This lightweight object is created for each `read()` or `write()` call via `read` / `write` descriptors on the data object class. The key driver is to allow complete format-specific documentation of available method options via a `help()` method, e.g. `Table.read.help('fits')`.

  Subclasses must define a `__call__` method which is what actually gets called when the data object `read()` or `write()` method is called.

  For the canonical example see the `Table` class implementation (in particular the `connect.py` module there).

  Parameters:
    instance `object`

      Descriptor calling instance or None if no instance

    cls type

      Descriptor calling class (either owner class or instance class)

    method_name `python:str`

      Method name, e.g. ‘read’ or ‘write’

    registry`_UnifiedIORegistryBase` or `python:None`, optional

      The IO registry.

  Attributes Summary

  `registry` | Unified I/O registry instance.

  Methods Summary

  `help`([format, out]) | Output help documentation for the specified unified I/O `format`.
  `list_formats`([out]) | Print a list of available formats to console (or `out` filehandle).

  Attributes Documentation

  registry

    Unified I/O registry instance.

  Methods Documentation

  help(format=None, out=None)

    Output help documentation for the specified unified I/O `format`.

    By default the help output is printed to the console via `pydoc.pager`. Instead one can supplied a file handle object as `out` and the output will be written to that handle.

    Parameters:
      format `python:str`

        Unified I/O format name, e.g. ‘fits’ or ‘ascii.ecsv’

      out `python:None` or python:file-like object

        Output destination (default is stdout via a pager)

    Raises:
      `RuntimeError`

        If called within a python runtime running with optimization level >= 2 (-OO CLI flag).

  list_formats(out=None)

    Print a list of available formats to console (or `out` filehandle).

    outNone or file handle object

      Output destination (default is stdout via a pager)