
[c           @` s  d  Z  d d l m Z m Z m Z m Z d d l m Z d d l m	 Z	 m
 Z
 d d l Z d d l Z d d l m Z d d l m Z d d l Z d d	 l m Z d d
 l m Z d d l m Z m Z m Z m Z m Z m Z m Z m Z m  Z  m! Z! m" Z" m# Z# m$ Z$ m% Z% m& Z& m' Z' m( Z( d d d g Z) e j* d  Z+ e j* d  Z, d Z- d Z. d Z/ e j0 sye Z1 e Z2 n d   Z1 d   Z2 e j3 d k rd   Z4 n	 d   Z4 d   Z5 d   Z6 d   Z7 d e8 f d     YZ9 d e9 f d      YZ: d! e9 f d"     YZ; d# e9 f d$     YZ< d% e< f d&     YZ= d' e= f d(     YZ> d) e= f d*     YZ? d+ e< f d,     YZ@ d- e9 f d.     YZA d/ eA f d0     YZB d1 eB f d2     YZC d3 eB f d4     YZD d5 eA f d6     YZE d7 eE f d8     YZF d9 eE f d:     YZG d; eE f d<     YZH d= eE f d>     YZI d? e= f d@     YZJ dA e= f dB     YZK dC e@ f dD     YZL dE eB e< f dF     YZM dG eM f dH     YZN dI eM f dJ     YZO dK e@ f dL     YZP dM e9 f dN     YZQ dO e@ f dP     YZR dQ e9 f dR     YZS i eC dS 6eD dT 6eQ dU 6eS dV 6eF dW 6eG dX 6eH dY 6eI dZ 6eN d[ 6eO d\ 6e: d] 6e; d^ 6ZT d d d_  ZV i
 dS e jW   jX jY 6dT e jZ   jX jY 6dU e j[   jX jY 6dW e j\   jX jY 6dX e j]   jX jY 6dY e j^   jX jY 6dZ e j_   jX jY 6d[ e j`   jX jY 6d\ e ja   jX jY 6d^ e jb   jX jY 6Zc d] ec e jd   jX jY <d`   Ze da   Zf db   Zg dc   Zh dd   Zi d S(e   ui   
This module handles the conversion of various VOTABLE datatypes
to/from TABLEDATA_ and BINARY_ formats.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsi   (   t   six(   t   ranget   zipN(   t   unpack(   t   pack(   t   ma(   t   xml_escape_cdatai   (   t   vo_raiset   vo_warnt   warn_or_raiset   W01t   W30t   W31t   W39t   W46t   W47t   W49t   W51t   E01t   E02t   E03t   E04t   E05t   E06u   get_converteru	   Converteru    table_column_to_votable_datatypeu    +u   \s+|(?:\s*,\s*)s       t    s    c         C` s   t  |  j d  |  S(   Nu   ascii(   t   _struct_unpackt   encode(   t   formatt   s(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   struct_unpack2   s    c         G` s   t  |  j d  |  S(   Nu   ascii(   t   _struct_packR   (   R   t   args(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   struct_pack5   s    u   littlec         C` s    |  j  j d k r |  j   S|  S(   Nu   >(   t   dtypet	   byteordert   byteswap(   t   x(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   _ensure_bigendian:   s    
c         C` s    |  j  j d k r |  j   S|  S(   Nu   <(   R%   R&   R'   (   R(   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR)   ?   s    
c         C` sQ   t  |   r7 t j t j |   d t j | d d St j t j |    Sd S(   u   
    Masked arrays of zero length that also have a mask of zero length
    cause problems in Numpy (at least in 1.6.2).  This function
    creates a masked array from data and a mask, unless it is zero
    length.
    t   maskR%   u   boolN(   t   lenR	   t   arrayt   np(   t   dataR*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   _make_masked_arrayE   s
    c         C` s   g  } x |  D] } t  j r+ t |  } n  xW t d d d  D]C } | d | >@} | d k } | j |  t |  | k r> Pq> q> Wt |  | k r Pq q Wt j | d d S(   u  
    Converts a bit array (a string of bits in a bytes object) to a
    boolean Numpy array.

    Parameters
    ----------
    data : bytes
        The bit array.  The most significant byte is read first.

    length : int
        The number of bits to read.  The least significant bits in the
        data bytes beyond length will be ignored.

    Returns
    -------
    array : numpy bool array
    i   ii   i    R%   u   b1(   R   t   PY2t   ordR   t   appendR+   R-   R,   (   R.   t   lengtht   resultst   bytet   bit_not   bit(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   bitarray_to_boolU   s    	c         C` s   |  j  }  d } d } g  } xW |  D]O } | r? | d | >O} n  | d k rg | j |  d } d } q" | d 8} q" W| d k r | j |  n  t d j t |   |  S(   u  
    Converts a numpy boolean array to a bit array (a string of bits in
    a bytes object).

    Parameters
    ----------
    value : numpy bool array

    Returns
    -------
    bit_array : bytes
        The first value in the input array will be the most
        significant bit in the result.  The length will be `floor((N +
        7) / 8)` where `N` is the length of `value`.
    i   i    i   u   {}B(   t   flatR2   R$   R   R+   (   t   valueR6   R5   t   bytest   v(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   bool_to_bitarrayw   s    		t	   Converterc           B` s}   e  Z d  Z d
 d
 d  Z e d    Z e d    Z d   Z d
 d
 d  Z	 d
 d
 d  Z
 d   Z d   Z d	   Z RS(   u  
    The base class for all converters.  Each subclass handles
    converting a specific VOTABLE data type to/from the TABLEDATA_ and
    BINARY_ on-disk representations.

    Parameters
    ----------
    field : `~astropy.io.votable.tree.Field`
        object describing the datatype

    config : dict
        The parser configuration dictionary

    pos : tuple
        The position in the XML file where the FIELD object was
        found.  Used for error messages.

    c         C` s   d  S(   N(    (   t   selft   fieldt   configt   pos(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   __init__   s    c         C` s   t  d |  d   d S(   Nu   >Ii   i    (   R!   (   t   read(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   _parse_length   s    c         C` s   t  d t |    S(   Nu   >I(   R$   t   int(   R3   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   _write_length   s    c         C` s   | j  d  S(   uF   
        Returns True when the field can be completely empty.
        u   version_1_3_or_later(   t   get(   R?   RA   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   supports_empty_values   s    c         C` s   t  d   d S(   u  
        Convert the string *value* from the TABLEDATA_ format into an
        object with the correct native in-memory datatype and mask flag.

        Parameters
        ----------
        value : str
            value in TABLEDATA format

        Returns
        -------
        native : tuple (value, mask)
            The value as a Numpy array or scalar, and *mask* is True
            if the value is missing.
        u.   This datatype must implement a 'parse' method.N(   t   NotImplementedError(   R?   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   parse   s    c         C` s   |  j  | | |  S(   u  
        Parse a single scalar of the underlying type of the converter.
        For non-array converters, this is equivalent to parse.  For
        array converters, this is used to parse a single
        element of the array.

        Parameters
        ----------
        value : str
            value in TABLEDATA format

        Returns
        -------
        native : tuple (value, mask)
            The value as a Numpy array or scalar, and *mask* is True
            if the value is missing.
        (   RK   (   R?   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   parse_scalar   s    c         C` s   t  d   d S(   u  
        Convert the object *value* (in the native in-memory datatype)
        to a unicode string suitable for serializing in the TABLEDATA_
        format.

        Parameters
        ----------
        value : native type corresponding to this converter
            The value

        mask : bool
            If `True`, will return the string representation of a
            masked value.

        Returns
        -------
        tabledata_repr : unicode
        u/   This datatype must implement a 'output' method.N(   RJ   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   output   s    c         C` s   t  d   d S(   u-  
        Reads some number of bytes from the BINARY_ format
        representation by calling the function *read*, and returns the
        native in-memory object representation for the datatype
        handled by *self*.

        Parameters
        ----------
        read : function
            A function that given a number of bytes, returns a byte
            string.

        Returns
        -------
        native : tuple (value, mask)
            The value as a Numpy array or scalar, and *mask* is True
            if the value is missing.
        u1   This datatype must implement a 'binparse' method.N(   RJ   (   R?   RD   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   binparse   s    c         C` s   t  d   d S(   u=  
        Convert the object *value* in the native in-memory datatype to
        a string of bytes suitable for serialization in the BINARY_
        format.

        Parameters
        ----------
        value : native type corresponding to this converter
            The value

        mask : bool
            If `True`, will return the string representation of a
            masked value.

        Returns
        -------
        bytes : byte string
            The binary representation of the value, suitable for
            serialization in the BINARY_ format.
        u2   This datatype must implement a 'binoutput' method.N(   RJ   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt	   binoutput  s    N(   t   __name__t
   __module__t   __doc__t   NoneRC   t   staticmethodRE   RG   RI   RK   RL   RM   RN   RO   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR>      s   			t   Charc           B` sw   e  Z d  Z e Z d
 d
 d  Z d   Z d
 d
 d  Z d
 d
 d  Z	 d   Z
 d   Z d   Z d   Z d	   Z RS(   u   
    Handles the char datatype. (7-bit unsigned characters)

    Missing values are not handled for string or unicode types.
    c         C` ss  | d  k r i  } n  t j |  | | |  | j d  k rY t t d	 | |  d | _ n  | j d k r d |  _ |  j |  _ |  j	 |  _
 d |  _ n | j j d  r | j d  | _ n  y t | j  |  _ Wn0 t k
 rt t | j d | j f |  n Xd j |  j  |  _ |  j |  _ |  j |  _
 d j |  j  |  _ | j d  rc|  j |  _ n |  j |  _ d  S(
   Nu   1u   *u   Oiu   charu   S{:d}u   >{:d}su   pedantic(    (   RS   R>   RC   t	   arraysizeR   R   R   t   _binparse_varRN   t   _binoutput_varRO   t   endswithRF   t
   ValueErrorR   R   t   IDt   _binparse_fixedt   _binoutput_fixedt   _struct_formatRH   t   _ascii_parseRK   t
   _str_parse(   R?   R@   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC   3  s0    		#c         C` s   t  S(   N(   t   True(   R?   RA   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRI   S  s    c         C` sV   |  j  d k rC t |  |  j  k rC t t d |  j  f | |  n  | j d  t f S(   Nu   *u   charu   ascii(   RV   R+   R   R   R   t   False(   R?   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR_   V  s    $c         C` sV   |  j  d k rC t |  |  j  k rC t t d |  j  f | |  n  | j d  t f S(   Nu   *u   charu   utf-8(   RV   R+   R   R   R   Rb   (   R?   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR`   [  s    $c         C` s5   | r
 d St  | t  s+ | j d  } n  t |  S(   Nu    u   ascii(   t
   isinstancet   strt   decodeR
   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM   `  s
    c         C` s   |  j  |  } | |  t f S(   N(   RE   Rb   (   R?   RD   R3   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRW   g  s    c         C` sR   t  |  j | |  j   d } | j t  } | d k rH | |  t f S| t f S(   Ni    i(   R!   R^   RV   t   findt
   _zero_byteRb   (   R?   RD   R    t   end(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR\   k  s
    c         C` s9   | s | d  k s | d k r" t S|  j t |   | S(   Nu    (   RS   t	   _zero_intRG   R+   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRX   r  s    c         C` s   | r t  } n  t |  j |  S(   N(   t   _empty_bytesR$   R^   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR]   w  s    	N(   RP   RQ   RR   Rj   t   defaultRS   RC   RI   R_   R`   RM   RW   R\   RX   R]   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRU   +  s    					t   UnicodeCharc           B` s_   e  Z d  Z d Z d	 d	 d  Z d	 d	 d  Z d   Z d   Z d   Z	 d   Z
 d   Z RS(
   ux   
    Handles the unicodeChar data type. UTF-16-BE.

    Missing values are not handled for string or unicode types.
    u    c         C` s  t  j |  | | |  | j d  k rD t t d | |  d | _ n  | j d k r d |  _ |  j |  _ |  j	 |  _
 d |  _ n y t | j  |  _ Wn0 t k
 r t t | j d | j f |  n Xd j |  j  |  _ |  j |  _ |  j |  _
 d j |  j d  |  _ d  S(	   Nu   1u   *u   Ou   unicodeu   U{:d}u   >{:d}si   (    (   R>   RC   RV   RS   R   R   R   RW   RN   RX   RO   RF   RZ   R   R   R[   R\   R]   R^   (   R?   R@   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s"    	#c         C` sM   |  j  d k rC t |  |  j  k rC t t d |  j  f | |  n  | t f S(   Nu   *u   unicodeChar(   RV   R+   R   R   Rb   (   R?   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK     s    $c         C` s   | r
 d St  t j |   S(   Nu    (   R
   R   t	   text_type(   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM     s    c         C` s,   |  j  |  } | | d  j d  t f S(   Ni   u	   utf_16_be(   RE   Re   Rb   (   R?   RD   R3   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRW     s    c         C` se   t  |  j | |  j d   d } | j d  } | j d  } | d k r[ | |  t f S| t f S(   Ni   i    u	   utf_16_beu    i(   R!   R^   RV   Re   Rf   Rb   (   R?   RD   R    Rh   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR\     s    #c         C` sL   | s | d  k s | d k r" t S| j d  } |  j t |  d  | S(   Nu    u	   utf_16_bei   (   RS   Ri   R   RG   R+   (   R?   R:   R*   t   encoded(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRX     s    c         C` s(   | r d } n  t  |  j | j d   S(   Nu    u	   utf_16_be(   R$   R^   R   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR]     s    	N(   RP   RQ   RR   Rk   RS   RC   RK   RM   RW   R\   RX   R]   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRl   }  s   				t   Arrayc           B` sV   e  Z d  Z d d d  Z d d d  Z e d d d   Z e d d d   Z RS(   u9   
    Handles both fixed and variable-lengths arrays.
    c         C` sY   | d  k r i  } n  t j |  | | |  | j d  rI |  j |  _ n |  j |  _ d  S(   Nu   pedantic(   RS   R>   RC   RH   t   _splitter_pedantict	   _splittert   _splitter_lax(   R?   R@   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s    	i    c         C` s   |  j  j | | |  S(   N(   t   _baseRL   (   R?   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRL     s    c         C` s   t  j |   S(   N(   t   pedantic_array_splittert   split(   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRp     s    c         C` s/   d |  k r" t  t d | |  n  t j |   S(   Nu   ,(    (   R   R   t   array_splitterRu   (   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRr     s    N(	   RP   RQ   RR   RS   RC   RL   RT   Rp   Rr   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRo     s   	t   VarArrayc           B` s>   e  Z d  Z d Z d d d  Z d   Z d   Z d   Z RS(   uJ   
    Handles variable lengths arrays (i.e. where *arraysize* is '*').
    u   Oc         C` s>   t  j |  | |  | |  _ t j g  d |  j j |  _ d  S(   NR%   (   Ro   RC   Rs   R-   R,   R   Rk   (   R?   R@   t   baseRV   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s    	c         C` sM   |  j  j } g  t j | |  D] \ } } | | |  ^ q } d j |  S(   Nu    (   Rs   RM   R-   t	   broadcastt   join(   R?   R:   R*   RM   R(   t   mt   result(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM     s    4c   	      C` s}   |  j  |  } g  } g  } |  j j } x@ t |  D]2 } | |  \ } } | j |  | j |  q4 Wt | |  t f S(   N(   RE   Rs   RN   R   R2   R/   Rb   (	   R?   RD   R3   R|   t   result_maskRN   t   it   valR*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRN     s    c         C` s   | d  k s t |  d k r" t St |  } |  j |  g } |  j j } x6 t | | j  D]" \ } } | j | | |   q_ Wt	 j
 |  S(   Ni    (   RS   R+   Ri   RG   Rs   RO   R   R*   R2   Rj   Rz   (   R?   R:   R*   R3   R|   RO   R(   R{   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRO     s    N(	   RP   RQ   RR   R   RS   RC   RM   RN   RO   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRw     s   		t   ArrayVarArrayc           B` s   e  Z d  Z d d d  Z RS(   u]   
    Handles an array of variable-length arrays, i.e. where *arraysize*
    ends in '*'.
    c         C` s	  | j    d k r% t j g   t f S|  j | | |  } |  j j } |  j j } t |  | d k r t	 t
 | t |  f | |  n  g  } g  } x] t d t |  |  D]C }	 | | |	 |	 | !| |  \ } }
 | j |  | j |
  q Wt | |  t f S(   Nu    i    (   t   stripR	   R,   Rb   Rq   Rs   t   _itemst   parse_partsR+   R   R   R   R2   R/   (   R?   R:   RA   RB   t   partst   itemsR   R|   R}   R~   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK   	  s    "#N(   RP   RQ   RR   RS   RK   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   t   ScalarVarArrayc           B` s   e  Z d  Z d d d  Z RS(   u=   
    Handles a variable-length array of numeric scalars.
    c   
      C` s   | j    d k r% t j g   t f S|  j | | |  } |  j j } g  } g  } x@ | D]8 } | | | |  \ } }	 | j |  | j |	  qY Wt | |  t f S(   Nu    (	   R   R	   R,   Rb   Rq   Rs   RK   R2   R/   (
   R?   R:   RA   RB   R   RK   R|   R}   R(   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK   !  s    N(   RP   RQ   RR   RS   RK   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   t   NumericArrayc           B` s\   e  Z d  Z e Z d d d  Z d d d  Z d d d  Z d   Z	 d   Z
 d   Z RS(   u:   
    Handles a fixed-length array of numeric scalars.
    c         C` s   t  j |  | | |  | |  _ | |  _ d j t |  | j  |  _ d |  _ x | D] } |  j | 9_ qV Wt j |  j  j	 |  _
 d |  j |  _ t j | d |  j j |  _ |  j j |  j d <d  S(   Nu   {}{}i   u   >R%   .(   Ro   RC   Rs   t
   _arraysizeR   t   tupleR   R-   R%   t   itemsizet   _memsizet   _bigendian_formatt   emptyRk   (   R?   R@   Rx   RV   RA   RB   t   dim(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC   8  s    			c         C` s9  | d  k r i  } n8 | d rM | d k rM t j |  j d |  j j t f S|  j | | |  } t |  |  j	 k r t
 t t |  j	 t |  f | |  n  | j d  r |  j | | |  St |  |  j	 k r nI t |  |  j	 k r | |  j	  } n$ | |  j j g |  j	 t |  } |  j | | |  Sd  S(   Nu   version_1_3_or_lateru    R%   u   pedantic(   RS   R-   t   zerosR   Rs   R   Ra   Rq   R+   R   R   R   RH   R   Rk   (   R?   R:   RA   RB   R   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK   I  s     	"(!c   
      C` s   |  j  j } g  } g  } x@ | D]8 } | | | |  \ } }	 | j |  | j |	  q Wt j | d |  j  j j |  j  } t j | d d j |  j  } | | f S(   NR%   u   bool(   Rs   RK   R2   R-   R,   R   t   reshapeR   (
   R?   R   RA   RB   t
   base_parseR|   R}   R(   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   ]  s    c         ` sV   |  j  j   t j |  } t j |  } d j   f d   t | j | j  D  S(   Nu    c         3` s$   |  ] \ } }   | |  Vq d  S(   N(    (   t   .0R(   R{   (   t   base_output(    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pys	   <genexpr>o  s    (   Rs   RM   R-   t   asarrayRz   R   R9   (   R?   R:   R*   (    (   R   s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM   k  s
    c         C` sA   t  j | |  j  d |  j d } |  j j |  } | | f S(   NR%   i    (   R-   t
   frombufferR   R   Rs   t   is_null(   R?   RD   R|   R}   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRN   r  s    c         C` s+   |  j  j | |  } t |  } | j   S(   N(   Rs   t   filter_arrayR)   t   tostring(   R?   R:   R*   t   filtered(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRO   x  s    N(   RP   RQ   RR   R   t   vararray_typeRS   RC   RK   R   RM   RN   RO   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   2  s   		t   Numericc           B` sA   e  Z d  Z e Z e Z d Z d d d  Z	 d   Z
 d   Z RS(   u4   
    The base class for all numeric data types.
    c         C` s   t  j |  | | |  t j |  j  j |  _ d |  j |  _ | j j	 d  k	 r t j | j j	 d |  j |  _	 |  j	 |  _ |  j |  _ n t j |  _ d  S(   Nu   >R%   (   R>   RC   R-   R%   R   R   R   R   t   valuest   nullRS   R   Rk   t   _is_nullR   t   isnan(   R?   R@   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s    !c         C` s<   t  j | |  j  d |  j } | d |  j | d  f S(   NR%   i    (   R-   R   R   R   R   (   R?   RD   R|   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRN     s    c         C` s   | |  j  k S(   N(   R   (   R?   R:   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s    N(   RP   RQ   RR   R   t
   array_typeR   R   RS   R   RC   RN   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   ~  s   	t   FloatingPointc           B` s   e  Z d  Z e j Z d
 d
 d  Z d   Z d
 d
 d  Z	 d
 d
 d  Z
 e d    Z d   Z d   Z d   Z d	   Z RS(   u6   
    The base class for floating-point datatypes.
    c         C` s  | d  k r i  } n  t j |  | | |  | j } | j } | d  k rU d g } n	 d g } | d  k	 r | j t j |   n  | d  k	 r| j d  r | j d j	 t
 | d    q| j d  r | j d j	 t
 | d    q| j d j	 t
 |    n  | j d  d	 j |  |  _ t j t j |  j	  |  _ |  j d  k rd
 |  _ |  j |  j t  |  _ |  j |  _ nN |  j t j |  j  t  |  _ |  j t j |  j  t  |  _ |  j |  _ | j d  r|  j |  _ n |  j |  _ d  S(   Nu   {!r:>u   {:u   Eu   .{:d}gi   u   Fu   .{:d}fu   }u    u   NaNu   pedantic(   RS   R   RC   t	   precisiont   widthR2   R   Rm   t
   startswithR   RF   Rz   t   _output_formatR-   R,   t   nanR   t   _null_outputRO   Rb   t   _null_binoutputt   _filter_nanR   RM   R   t   _filter_nullRH   t   _parse_pedanticRK   t   _parse_permissive(   R?   R@   RA   RB   R   R   t   format_parts(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s:    				##	!!c         C` s   t  S(   N(   Ra   (   R?   RA   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRI     s    c         C` s>   | j    d k r |  j t f St |  } | |  j |  f S(   Nu    (   R   R   Ra   t   floatR   (   R?   R:   RA   RB   t   f(    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s    c         C` sm   y# t  |  } | |  j |  f SWnC t k
 rh | j   d k r[ t t | | |  n  |  j t f SXd  S(   Nu    (   R   R   RZ   R   R   R   R   Ra   (   R?   R:   RA   RB   R   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s    c         C` s   |  j  S(   N(   R   (   R?   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   output_format  s    c         C` s   | r |  j  St j |  r t j |  s@ | j j |  } n  |  j j |  } | j d  rm t	    n  |  j d d k r | j
 d  r | d  } n  | St j |  r d St j |  r d St j |  r d St d	 j |   d  S(
   Nu   arrayi   u   ru   .0iu   NaNu   +InFu   -InFu!   Invalid floating point value '{}'(   R   R-   t   isfinitet   isscalarR%   t   typeR   R   R   t   RuntimeErrorRY   R   t   isposinft   isneginfR   (   R?   R:   R*   R|   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM     s&    c         C` s#   | r |  j  St |  } | j   S(   N(   R   R)   R   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRO     s    c         C` s   t  j | t  j |  S(   N(   R-   t   whereR   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s    c         C` s   t  j | |  j |  S(   N(   R-   R   R   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s    N(   RP   RQ   RR   R-   R   Rk   RS   RC   RI   R   R   t   propertyR   RM   RO   R   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   	-				t   Doublec           B` s   e  Z d  Z d Z RS(   uQ   
    Handles the double datatype.  Double-precision IEEE
    floating-point.
    u   f8(   RP   RQ   RR   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   
  s   t   Floatc           B` s   e  Z d  Z d Z RS(   uL   
    Handles the float datatype.  Single-precision IEEE floating-point.
    u   f4(   RP   RQ   RR   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   t   Integerc           B` sM   e  Z d  Z d Z d d d  Z d d d  Z d   Z d   Z d   Z	 RS(   u8   
    The base class for all the integral datatypes.
    i    c         C` s   t  j |  | | |  d  S(   N(   R   RC   (   R?   R@   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s    c         C` s  | d  k r i  } n  t } t | t j  r| j   } | d k r | d rX t } n t t t d
 | |  |  j	 d  k	 r |  j	 } q|  j
 } q'| d k r t } |  j	 d  k r t t t d | |  |  j
 } q|  j	 } q'| j d  r	t | d d  } q't | d  } n t |  } |  j	 d  k	 rN| |  j	 k rNt } n  | |  j d k  rt t t | |  j f | |  |  j d } nB | |  j d	 k rt t t | |  j f | |  |  j d	 } n  | | f S(   Nu    u   version_1_3_or_lateru   nanu   0xi   i   i
   i    i   (    (    (   RS   Rb   Rc   R   t   string_typest   lowerRa   R   R   R   Rk   R   R   RF   t	   val_rangeR   t   bit_size(   R?   R:   RA   RB   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK   "  s>    	
		c         C` sC   | r6 |  j  d  k r& t t t  d St j |  j   St j |  S(   Nu   NaN(   R   RS   R   R   R   Rm   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM   J  s    c         C` sD   | r. |  j  d  k r" t t  q. |  j  } n  t |  } | j   S(   N(   R   RS   R   R   R)   R   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRO   R  s    c         C` sE   t  j |  rA |  j d  k	 r4 t  j | |  j |  St t  n  | S(   N(   R-   t   anyR   RS   R   R   R   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   \  s
    N(
   RP   RQ   RR   Rk   RS   RC   RK   RM   RO   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   (		
t   UnsignedBytec           B` s    e  Z d  Z d Z d Z d Z RS(   uE   
    Handles the unsignedByte datatype.  Unsigned 8-bit integer.
    u   u1i    i   u   8-bit unsigned(   i    i   (   RP   RQ   RR   R   R   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   e  s   t   Shortc           B` s    e  Z d  Z d Z d Z d Z RS(   u=   
    Handles the short datatype.  Signed 16-bit integer.
    u   i2i i  u   16-bit(   i i  (   RP   RQ   RR   R   R   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   n  s   t   Intc           B` s    e  Z d  Z d Z d Z d Z RS(   u;   
    Handles the int datatype.  Signed 32-bit integer.
    u   i4i   iu   32-bit(   i   i(   RP   RQ   RR   R   R   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   w  s   t   Longc           B` s    e  Z d  Z d Z d Z d Z RS(   u<   
    Handles the long datatype.  Signed 64-bit integer.
    u   i8I       Iu   64-bit(   I       I(   RP   RQ   RR   R   R   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   t   ComplexArrayVarArrayc           B` s   e  Z d  Z d d d  Z RS(   uH   
    Handles an array of variable-length arrays of complex numbers.
    c         C` s	  | j    d k r% t j g   t f S|  j | | |  } |  j j } |  j j } t |  | d k r t	 t
 | t |  f | |  n  g  } g  } x] t d t |  |  D]C }	 | | |	 |	 | !| |  \ } }
 | j |  | j |
  q Wt | |  t f S(   Nu    i    (   R   R	   R,   Ra   Rq   Rs   R   R   R+   R   R   R   R2   R/   Rb   (   R?   R:   RA   RB   R   R   R   R|   R}   R~   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK     s    "#N(   RP   RQ   RR   RS   RK   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   t   ComplexVarArrayc           B` s   e  Z d  Z d d d  Z RS(   u=   
    Handles a variable-length array of complex numbers.
    c         C` s   | j    d k r% t j g   t f S|  j | | |  } |  j j } g  } g  } x| t d t |  d  D]b } g  | | | d !D] }	 t	 |	  ^ q } | | | |  \ } }
 | j
 |  | j
 |
  qk Wt t j | d |  j j |  t f S(   Nu    i    i   R%   (   R   R	   R,   Ra   Rq   Rs   R   R   R+   R   R2   R/   R-   R   Rb   (   R?   R:   RA   RB   R   R   R|   R}   R~   R(   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK     s    *N(   RP   RQ   RR   RS   RK   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   t   ComplexArrayc           B` sA   e  Z d  Z e Z d d d  Z d d d  Z d d d  Z RS(   u8   
    Handles a fixed-size array of complex numbers.
    c         C` s/   t  j |  | | | | |  |  j d 9_ d  S(   Ni   (   R   RC   R   (   R?   R@   Rx   RV   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s    c         C` s@   |  j  | | |  } | d g k r- g  } n  |  j | | |  S(   Nu    (   Rq   R   (   R?   R:   RA   RB   R   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK     s    	c         C` s   t  |  |  j k r: t t |  j t  |  f | |  n  |  j j } g  } g  } xy t d |  j d  D]b } g  | | | d !D] } t |  ^ q }	 | |	 | |  \ }	 }
 | j |	  | j |
  qh Wt	 j
 | d |  j j j |  j  } t	 j
 | d d j |  j  } | | f S(   Ni    i   R%   u   bool(   R+   R   R   R   Rs   R   R   R   R2   R-   R,   R   R   R   (   R?   R   RA   RB   R   R|   R}   R~   R(   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s    %*!N(	   RP   RQ   RR   R   R   RS   RC   RK   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s
   t   Complexc           B` se   e  Z d  Z e Z e Z e j Z	 d d d  Z d d d  Z e Z e Z d d d  Z d   Z RS(   u-   
    The base class for complex numbers.
    c         C` s0   t  j |  | | |  t j |  | | |  d  S(   N(   R   RC   Ro   (   R?   R@   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s    c         C` s   | j    } | d k s* | j   d k r7 t j t f S|  j } g  | | | |  D] } t |  ^ qS } t |  d k r t t	 | f | |  n  |  j
 | | |  S(   Nu    u   nani   (   R   R   R-   R   Ra   Rq   R   R+   R   R   R   (   R?   R:   RA   RB   t   strippedt   splitterR(   R   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK     s    	+c         C` s   t  |   } | |  j |  f S(   N(   t   complexR   (   R?   R   RA   RB   R:   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s    c         C` s   | r% |  j  d  k r d S|  j  } n  |  j j t | j   } |  j j t | j   } |  j d d k r | j d  r | d  } n  | j d  r | d  } q n  | d | S(   Nu   NaNi   u   ru   .0iu    (   R   RS   R   R   R   t   realt   imagRY   (   R?   R:   R*   R   R   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM     s    N(   RP   RQ   RR   R   R   R   R   R-   R   Rk   RS   RC   RK   R   R   R   RM   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   		t   FloatComplexc           B` s   e  Z d  Z d Z RS(   ub   
    Handle floatComplex datatype.  Pair of single-precision IEEE
    floating-point numbers.
    u   c8(   RP   RQ   RR   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   t   DoubleComplexc           B` s   e  Z d  Z d Z RS(   uc   
    Handle doubleComplex datatype.  Pair of double-precision IEEE
    floating-point numbers.
    u   c16(   RP   RQ   RR   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   t   BitArrayc           B` sh   e  Z d  Z e Z d d d  Z e d d d   Z e d d d   Z	 d   Z
 d   Z d   Z RS(   u#   
    Handles an array of bits.
    c         C` s8   t  j |  | | | | |  |  j d d d |  _ d  S(   Ni   i   (   R   RC   R   t   _bytes(   R?   R@   Rx   RV   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRC     s    c         C` s   t  t j d d |    S(   Nu   \su    (   t   listt   ret   sub(   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRp   !  s    c         C` s;   d |  k r" t  t d | |  n  t t j d d |    S(   Nu   ,u   \s|,u    (    (   R   R   R   R   R   (   R:   RA   RB   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRr   %  s    c         ` s_   t  j |  r t t  n  t  j |  } i d t 6d t 6  d j   f d   | j D  S(   Nu   0u   1u    c         3` s   |  ] }   | Vq d  S(   N(    (   R   R(   (   t   mapping(    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pys	   <genexpr>0  s    (	   R-   R   R   R   R   Rb   Ra   Rz   R9   (   R?   R:   R*   (    (   R   s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM   +  s
    c         C` sU   | |  j   } t | |  j  } | j |  j  } t j |  j d d } | | f S(   NR%   u   b1(   R   R8   R   R   R   R-   R   (   R?   RD   R.   R|   R}   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRN   2  s
    c         C` s&   t  j |  r t t  n  t |  S(   N(   R-   R   R   R   R=   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRO   9  s    N(   RP   RQ   RR   R   R   RS   RC   RT   Rp   Rr   RM   RN   RO   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s   		t   Bitc           B` s\   e  Z d  Z d Z e Z e Z e Z	 d Z
 d Z d d d  Z d   Z d   Z d   Z RS(	   u#   
    Handles the bit datatype.
    u   b1s   s    c         C` s   | d  k r i  } n  i t d 6t d 6} | t k sG | j   d k rt | d sj t t t d | |  n  t t f Sy | | t f SWn' t k
 r t t | f | |  n Xd  S(   Nu   1u   0u    u   version_1_3_or_later(    (	   RS   Ra   Rb   R   R   R   t   KeyErrorR   R   (   R?   R:   RA   RB   R   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK   K  s    	

c         C` s%   | r t  t  n  | r d Sd Sd  S(   Nu   1u   0(   R   R   (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM   Y  s
    c         C` s&   | d  } t  |  d @d k t f S(   Ni   i   i    (   R1   Rb   (   R?   RD   R.   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRN   b  s    c         C` s'   | r t  t  n  | r  |  j S|  j S(   N(   R   R   t
   binary_onet   binary_zero(   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRO   f  s
    N(   RP   RQ   RR   R   R   R   R   R   Rb   Rk   R   R   RS   RK   RM   RN   RO   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   @  s   			t   BooleanArrayc           B` s&   e  Z d  Z e Z d   Z d   Z RS(   u-   
    Handles an array of boolean values.
    c   	      C` s   | |  j   } |  j j } g  } g  } xR | D]J } t j rL t |  } n  | |  \ } } | j |  | j |  q. Wt j | d d j	 |  j
  } t j | d d j	 |  j
  } | | f S(   NR%   u   b1(   R   Rs   t   binparse_valueR   R0   R1   R2   R-   R,   R   R   (	   R?   RD   R.   RN   R|   R}   t   charR:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRN   u  s    	c         C` sq   |  j  j } t j |  } t j |  } g  t j | j | j  D] \ } } | | |  ^ qC } t j |  S(   N(   Rs   RO   R-   R   Ry   R9   Rj   Rz   (   R?   R:   R*   RO   R(   R{   R|   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRO     s    7(   RP   RQ   RR   R   R   RN   RO   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR   o  s   	t   Booleanc           B` s  e  Z d  Z d Z e Z e Z e Z	 d Z
 d Z d Z d d d  Z d   Z d   Z i	 e e f e d  6e e f e d	  6e e f e d
  6e e f e d  6e e f e d  6e e f e d  6e e f e d  6e e f e d  6e e f e d  6Z d   Z d   Z RS(   u'   
    Handles the boolean datatype.
    u   b1t   ?t   Tt   Fc         C` s   | d k r t  t f S| t  k r, t  t f Si
 t t  f d 6t  t  f d 6t t  f d 6t  t  f d 6t t  f d 6t  t  f d 6t  t f d 6t  t f d	 6t  t f d
 6t  t f d 6} y | | j   SWn' t k
 r t t | f | |  n Xd  S(   Nu    u   TRUEu   FALSEu   1u   0u   Tu   Fu    u    u   ?(   Rb   Ra   t   upperR   R   R   (   R?   R:   RA   RB   R   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRK     s$    

c         C` s   | r
 d S| r d Sd S(   Nu   ?u   Tu   F(    (   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRM     s
    c         C` s   t  | d   } |  j |  S(   Ni   (   R1   R   (   R?   RD   R:   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRN     s    u   Tu   tu   1u   Fu   fu   0u    u    u   ?c         C` s7   y |  j  | SWn! t k
 r2 t t | f  n Xd  S(   N(   t   _binparse_mappingR   R   R   (   R?   R:   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s    c         C` s!   | r |  j  S| r |  j S|  j S(   N(   t   binary_question_markt   binary_truet   binary_false(   R?   R:   R*   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyRO     s
    N(   RP   RQ   RR   R   R   R   R   R   Rb   Rk   R   R   R   RS   RK   RM   RN   Ra   R1   R   R   RO   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyR     s.   			u   doubleu   floatu   bitu   booleanu   unsignedByteu   shortu   intu   longu   floatComplexu   doubleComplexu   charu   unicodeCharc   	      C` ss  | d k r i  } n  |  j t k rC t t |  j |  j f |  n  t |  j } | |  | |  } |  j } |  j d k ro| d k	 ro| d d k r | d  } | j d  } | d k r d } n
 | |  } t } n t	 } | d k rg  | j
 d  D] } t |  ^ q } | j   n g  } | g  k rK| j |  | | |  } n  | so| j |  | | |  } qon  | S(	   ut  
    Get an appropriate converter instance for a given field.

    Parameters
    ----------
    field : astropy.io.votable.tree.Field

    config : dict, optional
        Parser configuration dictionary

    pos : tuple
        Position in the input XML file.  Used for error messages.

    Returns
    -------
    converter : astropy.io.votable.converters.Converter
    u   charu   unicodeChariu   *u   xu    N(   u   charu   unicodeChar(   RS   t   datatypet   converter_mappingR   R   R[   RV   t   rfindRb   Ra   Ru   RF   t   reverseR   R   (	   R@   RA   RB   t   clst	   converterRV   t   last_xt   fixedR(   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   get_converter  s8    		
	
	(c         C` s(   x! |  D] } t  | t  s t Sq Wt S(   N(   Rc   R;   Rb   Ra   (   t   columnR(   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt
   _all_bytes0  s    c         C` s+   x$ |  D] } t  | t j  s t Sq Wt S(   N(   Rc   R   Rm   Rb   Ra   (   R   R(   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   _all_unicode7  s    c         C` s   t  } d } x |  D] } t | t j  s t |  d k rD q n  | t  k ri | j } | j d } q | | j k r t  d f S| | j d k r d } q q W| | f S(   Ni    i   (    (    (    (   Rb   Rc   R-   t   ndarrayR+   R%   t   shape(   R   t   first_dtypet   first_shapeR(   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   _all_matching_dtype>  s    %	
c         C` s   |  j  t k r' t d j |     n  |  j d k rQ i d d 6t |  j  d 6S|  j d k r i d d 6t |  j d  d 6Si t |  j  d 6} t |  r d	 j d
   | D  | d <n  | Sd S(   us  
    Converts a numpy dtype and shape to a dictionary of attributes for
    a VOTable FIELD element and correspond to that type.

    Parameters
    ----------
    dtype : Numpy dtype instance

    shape : tuple

    Returns
    -------
    attributes : dict
       A dict containing 'datatype' and 'arraysize' keys that can be
       set on a VOTable FIELD element.
    u'   {0!r} can not be represented in VOTableu   Su   charu   datatypeu	   arraysizeu   Uu   unicodeChari   u   xc         s` s   |  ] } t  |  Vq d  S(   N(   Rd   (   R   R(   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pys	   <genexpr>n  s    N(	   t   numt   numpy_dtype_to_field_mappingt	   TypeErrorR   R   Rd   R   R+   Rz   (   R%   R   R|   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   numpy_to_votable_dtypeO  s    

 c         C` s!  |  j  j d k r
t |  d t  rJ t |  d  r i d d 6d d 6Sn t |  d t j  r t |  d  r i d d 6d d 6Sns t |  d t j	  r t
 |   \ } } | t k	 r t | |  } d | k r d | d <n | d c d 7<| Sn  i d d 6d d 6St |  j  |  j d  S(	   u  
    Given a `astropy.table.Column` instance, returns the attributes
    necessary to create a VOTable FIELD element that corresponds to
    the type of the column.

    This necessarily must perform some heuristics to determine the
    type of variable length arrays fields, since they are not directly
    supported by Numpy.

    If the column has dtype of "object", it performs the following
    tests:

       - If all elements are byte or unicode strings, it creates a
         variable-length byte or unicode field, respectively.

       - If all elements are numpy arrays of the same dtype and with a
         consistent shape in all but the first dimension, it creates a
         variable length array of fixed sized arrays.  If the dtypes
         match, but the shapes do not, a variable length array is
         created.

    If the dtype of the input is not understood, it sets the data type
    to the most inclusive: a variable length unicodeChar array.

    Parameters
    ----------
    column : `astropy.table.Column` instance

    Returns
    -------
    attributes : dict
       A dict containing 'datatype' and 'arraysize' keys that can be
       set on a VOTable FIELD element.
    u   Oi    i   u   charu   datatypeu   *u	   arraysizeu   unicodeChar(   R%   R   Rc   R;   R   R   Rm   R   R-   R   R   Rb   R   R   (   R   R%   R   R|   (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt    table_column_to_votable_datatypes  s"    #(j   RR   t
   __future__R    R   R   R   t   externR   t   extern.six.movesR   R   R   t   syst   structR   R   R   R"   t   numpyR-   R	   t   utils.xml.writerR
   t
   exceptionsR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   __all__t   compileRt   Rv   Ri   Rj   Rg   R0   R!   R$   R&   R)   R/   R8   R=   t   objectR>   RU   Rl   Ro   Rw   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   RS   R   t   float64R%   R   t   float32t   bool_t   uint8t   int16t   int32t   int64t	   complex64t
   complex128t   unicode_R   t   bytes_R   R   R   R   R   (    (    (    s<   lib/python2.7/site-packages/astropy/io/votable/converters.pyt   <module>   s   "p							"	#R@*LoL				",*/ D
=				$