
                         j    d Z ddlZddlmZmZmZ  G d de      Z e       dd Z G d de      Z	d	 Z
y)
zDNS Wire Data Helper    N   )binary_typestring_typesPY2c                       e Zd Zd Zerd Zyy)_SliceUnspecifiedBoundc                     |j                   S N)stop)selfkeys     lib/third_party/dns/wiredata.py__getitem__z"_SliceUnspecifiedBound.__getitem__    s    xx    c                 8    | j                  t        ||            S r
   r   slicer   ijs      r   __getslice__z#_SliceUnspecifiedBound.__getslice__$       ##E!QK00r   N)__name__
__module____qualname__r   r   r    r   r   r   r      s     	1 r   r   c                   4     e Zd Z fdZerd Zd Zd Z xZS )WireDatac                 |   	 t        |t              r|j                  }|j                  }t        rg|t
        k(  rt        |       }|dk  s|dk  rt        j                  j                  ||k7  rgt        t        | 3  |       t        t        | 3  |dz
         n=||fD ]6  }|t        |      t        |       kD  st        j                  j                   t        t        t        | 3  t        ||                  S t        | j                               |   S # t         $ r t        j                  j                  w xY wNr   r   )
isinstancer   startr   r   _unspecified_boundlendns	exception	FormErrorsuperr   r   abs	bytearrayunwrap
IndexError)r   r   r"   r   index	__class__s        r   r   zWireData.__getitem__-   s   	*#u% 		xx11"4yqyD1H!mm555 }h9%@h9$(C"' =$ Z#d)3"%--"9"99	 "/  h A%&!( ) )T[[]+C00 	*--)))	*s   B6D :A D ;D $D;c                 8    | j                  t        ||            S r
   r   r   s      r   r   zWireData.__getslice__P   r   r   c              #   z   K   d}	 	 | |    |dz  }# t         j                  j                  $ r t        w xY wwr    )r%   r&   r'   StopIteration)r   r   s     r   __iter__zWireData.__iter__S   sJ     $1gQ  ==** $##$s   ; ;$8;c                     t        |       S r
   )r   )r   s    r   r+   zWireData.unwrap\   s    4  r   )	r   r   r   r   r   r   r2   r+   __classcell__)r.   s   @r   r   r   *   s     *D 	1$!r   r   c                     t        | t              r| S t        | t              rt        |       S t        | t              rt        | j	                               S t        dt        |       z        )Nzunhandled type %s)r!   r   r   r   encode
ValueErrortype)wires    r   
maybe_wrapr:   `   sU    $!	D+	&~	D,	'&&
(4:5
66r   )__doc__dns.exceptionr%   _compatr   r   r   r   r#   r   r:   r   r   r   <module>r>      sC   $   3 31[ 1 ,-ab1 3!{ 3!l7r   