
    IR-e                     T    d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 d Z
ddZdS )	a  
``showtable`` is a command-line script based on ``astropy.io`` and
``astropy.table`` for printing ASCII, FITS, HDF5 or VOTable files(s) to the
standard output.

Example usage of ``showtable``:

1. FITS::

    $ showtable astropy/io/fits/tests/data/table.fits

     target V_mag
    ------- -----
    NGC1001  11.1
    NGC1002  12.3
    NGC1003  15.2

2. ASCII::

    $ showtable astropy/io/ascii/tests/t/simple_csv.csv

     a   b   c
    --- --- ---
      1   2   3
      4   5   6

3. XML::

    $ showtable astropy/io/votable/tests/data/names.xml --max-width 70

               col1             col2     col3  ... col15 col16 col17
               ---              deg      deg   ...  mag   mag   ---
    ------------------------- -------- ------- ... ----- ----- -----
    SSTGLMC G000.0000+00.1611   0.0000  0.1611 ...    --    --    AA



4. Print all the FITS tables in the current directory::

    $ showtable *.fits

    N)log)Table)AstropyUserWarningc                    |j         r!|j        rt          j        dt                     t          |j        |j        |j        |j	        f          r(|j         s|j        rt          j        dt                     dfdt          |                                          D             }	 t          j        | fi |}|j         r|                     d           dS |j        r|                     d           dS |j        r|j        n|j        } ||j        |j        |j        rdnd|j	        rd	nd
           dS # t           $ r,}t#          j        t'          |                     Y d}~dS d}~ww xY w)z
    Read a table and print to the standard output.

    Parameters
    ----------
    filename : str
        The path to a FITS file.

    z*--info and --stats cannot be used togetherz9print parameters are ignored if --info or --stats is used)hduformattable_id	delimiterc                 (    i | ]\  }}|v 	|||S N ).0kvread_kwargss      ?lib/python3.11/site-packages/astropy/table/scripts/showtable.py
<dictcomp>zshowtable.<locals>.<dictcomp>M   s*    XXXtq!Q+5E5E!-a---    
attributesstatsFNT)	max_lines	max_width	show_unit
show_dtype)infor   warningswarnr   anyr   r   	hide_unitr   varsitemsr   readmorepprintOSErrorr   errorstr)filenameargskwargstable	formatterer   s         @r   	showtabler.   6   s    y XTZ XBDVWWW
DNDNDNDOLMM 
	
Z
 	G	
 	
 	
 =KXXXXtDzz//11XXXF
8..v..9 	JJ|$$$$$Z 		JJw&*iA

U\II..$(N<55$(O=DD	         	#a&&s%   ).D9 D9 7A D9 9
E/!E**E/c                    t          j        t          j        d                    }|j        } |ddd            |dd	            |d
dd            |ddd            |ddd           |                    d          }|j        } |dt          d            |dt          d            |ddd            |ddd           |                    d          }|j        } |dd	           |                    d          }|j        } |d d!	           |                    d"          }|j        } |d#d$	           |                    d%          }|j        } |d&d'	           |                    |           } t          | j	                  D ])\  }}	|d(k    rt                       t          |	|            *d)S )*z3The main function called by the `showtable` script.a  
            Print tables from ASCII, FITS, HDF5, VOTable file(s).  The tables
            are read with 'astropy.table.Table.read' and are printed with
            'astropy.table.Table.pprint'. The default behavior is to make the
            table output fit onto a single screen page.  For a long and wide
            table this will mean cutting out inner rows and columns.  To print
            **all** the rows or columns use ``--max-lines=-1`` or
            ``max-width=-1``, respectively. The complete list of supported
            formats can be found at
            http://astropy.readthedocs.io/en/latest/io/unified.html#built-in-table-readers-writers
        )descriptionr(   +zpath to one or more files)nargshelpz--formatzNinput table format, should be specified if it cannot be automatically detected)r3   z--more
store_truez"use the pager mode from Table.more)actionr3   z--infoz(show information about the table columnsz--statsz'show statistics about the table columnszpprint argumentsz--max-lineszPmaximum number of lines in table output (default=screen length, -1 for no limit))typer3   z--max-widthzEmaximum width in table output (default=screen width, -1 for no limit)z--hide-unitzThide the header row for unit (which is shown only if one or more columns has a unit)z--show-dtypezfalways include a header row for column dtypes (otherwise shown only if any column is multidimensional)zASCII argumentsz--delimiterzcolumn delimiter stringzFITS argumentsz--hduzname of the HDU to showzHDF5 argumentsz--pathz%the path from which to read the tablezVOTable argumentsz
--table-idzthe table to read inr   N)argparseArgumentParsertextwrapdedentadd_argumentadd_argument_groupint
parse_args	enumerater(   printr.   )
r)   parseraddargpprint_args
ascii_args	fits_args	hdf5_argsvotable_argsidxr(   s
             r   mainrI   `   s   $O

 
  F   F
F:S'BCCCC
F/    F8L/STTTT
F,V    F,-V   
 ++,>??K%F
F'	    FT   
 F6	    FG	    **+<==J$F
F=89999 ))*:;;I#F
F723333 ))*:;;I#F
F8ABBBB ,,-@AAL&F
F<45555T""D"4=11 " "X77GGG(D!!!!" "r   r   )__doc__r7   r9   r   astropyr   astropy.tabler   astropy.utils.exceptionsr   r.   rI   r   r   r   <module>rN      s   ) )V                7 7 7 7 7 7' ' 'T^" ^" ^" ^" ^" ^"r   