a
    ߙfb                     @   sP   d dl mZ ddlmZ ddgZddgZG dd dejZG dd dejZdS )	    registry   )serialize_method_as	TableRead
TableWritec                       s(   e Zd ZdZ fddZdd Z  ZS )r   ax  Read and parse a data table and return as a Table.

    This function provides the Table interface to the astropy unified I/O
    layer.  This allows easily reading a file in many supported data formats
    using syntax such as::

      >>> from astropy.table import Table
      >>> dat = Table.read('table.dat', format='ascii')
      >>> events = Table.read('events.fits', format='fits')

    Get help on the available readers for ``Table`` using the``help()`` method::

      >>> Table.read.help()  # Get help reading Table and list supported formats
      >>> Table.read.help('fits')  # Get detailed help on Table FITS reader
      >>> Table.read.list_formats()  # Print list of available formats

    See also: https://docs.astropy.org/en/stable/io/unified.html

    Parameters
    ----------
    *args : tuple, optional
        Positional arguments passed through to data reader. If supplied the
        first argument is typically the input filename.
    format : str
        File format specifier.
    units : list, dict, optional
        List or dict of units to apply to columns
    descriptions : list, dict, optional
        List or dict of descriptions to apply to columns
    **kwargs : dict, optional
        Keyword arguments passed through to data reader.

    Returns
    -------
    out : `~astropy.table.Table`
        Table corresponding to file contents

    Notes
    -----
    c                    s   t  j||dd d d S )Nreadr   super__init__selfinstancecls	__class__ 4lib/python3.9/site-packages/astropy/table/connect.pyr   5   s    zTableRead.__init__c                 O   s   | j }|dd }|dd }| jj|g|R i |}||jurvz||dd}W n" tyt   td|jY n0 |	d| |	d| |S )NunitsdescriptionsF)copyz,could not convert reader output to {} class.ZunitZdescription)
_clspopr   r   r   	Exception	TypeErrorformat__name__Z_set_column_attribute)r   argskwargsr   r   r   outr   r   r   __call__9   s    
zTableRead.__call__r   
__module____qualname____doc__r   r    __classcell__r   r   r   r   r      s   )c                       s.   e Zd ZdZ fddZddddZ  ZS )r   as  
    Write this Table object out in the specified format.

    This function provides the Table interface to the astropy unified I/O
    layer.  This allows easily writing a file in many supported data formats
    using syntax such as::

      >>> from astropy.table import Table
      >>> dat = Table([[1, 2], [3, 4]], names=('a', 'b'))
      >>> dat.write('table.dat', format='ascii')

    Get help on the available writers for ``Table`` using the``help()`` method::

      >>> Table.write.help()  # Get help writing Table and list supported formats
      >>> Table.write.help('fits')  # Get detailed help on Table FITS writer
      >>> Table.write.list_formats()  # Print list of available formats

    The ``serialize_method`` argument is explained in the section on
    `Table serialization methods
    <https://docs.astropy.org/en/latest/io/unified.html#table-serialization-methods>`_.

    See also: https://docs.astropy.org/en/stable/io/unified.html

    Parameters
    ----------
    *args : tuple, optional
        Positional arguments passed through to data writer. If supplied the
        first argument is the output filename.
    format : str
        File format specifier.
    serialize_method : str, dict, optional
        Serialization method specifier for columns.
    **kwargs : dict, optional
        Keyword arguments passed through to data writer.

    Notes
    -----
    c                    s   t  j||dd d d S )Nwriter   r	   r   r   r   r   r   z   s    zTableWrite.__init__N)serialize_methodc                O   sN   | j }t||* | jj|g|R i | W d    n1 s@0    Y  d S )N)Z	_instancer   r   r&   )r   r'   r   r   r   r   r   r   r    ~   s    zTableWrite.__call__r!   r   r   r   r   r   R   s   'N)	Z
astropy.ior   infor   __all__Z__doctest_skip__ZUnifiedReadWriter   r   r   r   r   r   <module>   s
   G