B
    d^                 @   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   ai  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 : `Table`
        Table corresponding to file contents

    Notes
    -----
    c                s   t  ||d d S )Nread)super__init__)selfinstancecls)	__class__ b/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/astropy/table/connect.pyr	   5   s    zTableRead.__init__c             O   s   | j }|dd }|dd }tj|f||}||jk	rpy||dd}W n$ tk
rn   td|jY nX |	d| |	d| |S )NunitsdescriptionsF)copyz,could not convert reader output to {} class.unitdescription)
_clspopr   r   r   	Exception	TypeErrorformat__name__Z_set_column_attribute)r
   argskwargsr   r   r   outr   r   r   __call__8   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  ||d d S )Nwrite)r   r	   )r
   r   r   )r   r   r   r	   y   s    zTableWrite.__init__N)serialize_methodc         	   O   s2   | j }t|| tj|f|| W d Q R X 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"   r   r   )r   r   r   Q   s   &N)	Z
astropy.ior   infor   __all__Z__doctest_skip__ZUnifiedReadWriter   r   r   r   r   r   <module>   s
   F