U
    e»{jš  ã                   @   sˆ   d dl Z d dlmZ d dlmZ d dlmZ d dlm	Z	 ddd„Z
ddd	„Zd
d„ Ze	js„e dee
¡ e dee¡ e dee¡ dS )é    N)Úregistry)Úcreate_asdf_deprecation_warning)ÚTable)Úoptional_depsc              
   K   s–   t  tƒ ¡ zddl}W n tk
r4   tdƒ‚Y nX |rF|rFtdƒ‚|j| f|Ž�8}|rp||jƒW  5 Q R £ S ||pxd W  5 Q R £ S W 5 Q R X dS )a‹  
    Read a `~astropy.table.Table` object from an ASDF file

    This requires `asdf <https://pypi.org/project/asdf/>`_ to be installed.
    By default, this function will look for a Table object with the key of
    ``data`` in the top-level ASDF tree. The parameters ``data_key`` and
    ``find_key`` can be used to override the default behavior.

    This function is registered as the Table reader for ASDF files with the
    unified I/O interface.

    Parameters
    ----------
    filename : str or :class:`py.lath:local`
        Name of the file to be read
    data_key : str
        Optional top-level key to use for finding the Table in the tree. If not
        provided, uses ``data`` by default. Use of this parameter is not
        compatible with ``find_table``.
    find_table : function
        Optional function to be used for locating the Table in the tree. The
        function takes a single parameter, which is a dictionary representing
        the top of the ASDF tree. The function must return a
        `~astropy.table.Table` instance.

    Returns
    -------
    table : `~astropy.table.Table`
        `~astropy.table.Table` instance
    r   Nú8The asdf module is required to read and write ASDF filesz6Options 'data_key' and 'find_table' are not compatibleÚdata)	ÚwarningsÚwarnr   ÚasdfÚImportErrorÚ	ExceptionÚ
ValueErrorÚopenÚtree)ÚfilenameÚdata_keyZ
find_tableÚkwargsr
   Úaf© r   ú[/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/io/misc/asdf/connect.pyÚ
read_table   s    r   c              	   K   sˆ   t  tƒ ¡ zddl}W n tk
r4   tdƒ‚Y nX |rF|rFtdƒ‚|rT|| ƒ}n|pZd| i}| |¡�}|j|f|Ž W 5 Q R X dS )a–  
    Write a `~astropy.table.Table` object to an ASDF file.

    This requires `asdf <https://pypi.org/project/asdf/>`_ to be installed.
    By default, this function will write a Table object in the top-level ASDF
    tree using the key of ``data``. The parameters ``data_key`` and
    ``make_tree`` can be used to override the default behavior.

    This function is registered as the Table writer for ASDF files with the
    unified I/O interface.

    Parameters
    ----------
    table : `~astropy.table.Table`
        `~astropy.table.Table` instance to be written
    filename : str or :class:`py.path:local`
        Name of the new ASDF file to be created
    data_key : str
        Optional top-level key in the ASDF tree to use when writing the Table.
        If not provided, uses ``data`` by default. Use of this parameter is not
        compatible with ``make_tree``.
    make_tree : function
        Optional function to be used for creating the ASDF tree. The function
        takes a single parameter, which is the `~astropy.table.Table` instance
        to be written. The function must return a `dict` representing the ASDF
        tree to be created.
    r   Nr   z5Options 'data_key' and 'make_tree' are not compatibler   )	r   r	   r   r
   r   r   r   ZAsdfFileZwrite_to)Útabler   r   Z	make_treer   r
   r   r   r   r   r   Úwrite_table;   s    
r   c                 O   s6   zdd l }W n tk
r"   Y dS X |d k	o4| d¡S )Nr   Fz.asdf)r
   r   Úendswith)ÚoriginÚfilepathÚfileobjÚargsr   r
   r   r   r   Úasdf_identifyj   s
    r   r
   )NN)NN)r   Z
astropy.ior   Zio_registryZ astropy.io.misc.asdf.deprecationr   Zastropy.tabler   Zastropy.utils.compatr   r   r   r   ZHAS_ASDF_ASTROPYZregister_readerZregister_writerZregister_identifierr   r   r   r   Ú<module>   s   
0
/	