B
    à%Q[#‡ ã               @   sT  d dl Z 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lm	Z	 d dl
mZ d dl
mZ d d	l
mZ d d
l
mZ d dl
mZ d dl
mZ ejZeƒ ZddddddddddddddddddgZG dd„ dejƒZG d d„ deƒZejd  d!k rþeZneZG d"d#„ d#eƒZG d$d„ dejƒZye W n ek
�rJ   d%d&„ ZY nX G d'd„ dejƒZG d(d„ deƒZ ejd  d)k�rˆeefZ!nefZ!e!e"f Z#G d*d„ dejƒZ$G d+d„ dejƒZ%G d,d„ deƒZ&G d-d„ dej'ƒZ(G d.d„ de(ƒZ)G d/d„ de(ƒZ*G d0d„ dej'ƒZ+G d1d„ de+ƒZ,G d2d„ de+ƒZ-G d3d„ de-ƒZ.G d4d„ deƒZ/dS )5é    N)Úerror)Úeoo)Úbinary)Úinteger)Úoctets)Úbase)Ú
constraint)Ú	namedtype)Únamedval)Útag)ÚtagmapÚIntegerÚBooleanÚ	BitStringÚOctetStringÚNullÚObjectIdentifierÚRealÚ
EnumeratedÚSequenceOfAndSetOfBaseÚ
SequenceOfÚSetOfÚSequenceAndSetBaseÚSequenceÚSetÚChoiceÚAnyÚNoValueÚnoValuec               @   s  e Zd ZdZe e ejejd¡¡Z	e
 ¡ Ze ¡ Zej ¡ Zefdd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z dd„ Z!dd„ Z"dd „ Z#d!d"„ Z$d#d$„ Z%dfd&d'„Z&d(d)„ Z'd*d+„ Z(d,d-„ Z)e*j+d. dk�rd/d0„ Z,d1d2„ Z-n(d3d4„ Z.d5d6„ Z/d7d8„ Z0d9d:„ Z1ejj2Z2d;d<„ Z3e*j+d. dk�rVd=d>„ Z4d?d@„ Z5dAdB„ Z6dCdD„ Z7dEdF„ Z8dGdH„ Z9dIdJ„ Z:dgdKdL„Z;dMdN„ Z<dOdP„ Z=e*j+d.d… dQk�r¼dRdS„ Z>dTdU„ Z?dVdW„ Z@dXdY„ ZAdZd[„ ZBd\d]„ ZCd^d_„ ZDd`da„ ZEdbdc„ ZFddde„ ZGd%S )hr   a  Create |ASN.1| type or object.

    |ASN.1| objects are immutable and duck-type Python :class:`int` objects.

    Keyword Args
    ------------
    value: :class:`int`, :class:`str` or |ASN.1| object
        Python integer or string literal or |ASN.1| class instance.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
        Object representing non-default symbolic aliases for numbers

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------

    .. code-block:: python

        class ErrorCode(Integer):
            '''
            ASN.1 specification:

            ErrorCode ::=
                INTEGER { disk-full(1), no-disk(-1),
                          disk-not-formatted(2) }

            error ErrorCode ::= disk-full
            '''
            namedValues = NamedValues(
                ('disk-full', 1), ('no-disk', -1),
                ('disk-not-formatted', 2)
            )

        error = ErrorCode('disk-full')
    é   c             K   s(   d|kr| j |d< tjj| |f|Ž d S )NÚnamedValues)r    r   ÚAbstractSimpleAsn1ItemÚ__init__)ÚselfÚvalueÚkwargs© r&   úTC:\Users\HIRONO~1\AppData\Local\Temp\pip-install-6i93dh7p\pyasn1\pyasn1\type\univ.pyr"   c   s    
zInteger.__init__c             C   s   |   | j|@ ¡S )N)ÚcloneÚ_value)r#   r$   r&   r&   r'   Ú__and__i   s    zInteger.__and__c             C   s   |   || j@ ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__rand__l   s    zInteger.__rand__c             C   s   |   | j|B ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__or__o   s    zInteger.__or__c             C   s   |   || jB ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__ror__r   s    zInteger.__ror__c             C   s   |   | j|A ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__xor__u   s    zInteger.__xor__c             C   s   |   || jA ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__rxor__x   s    zInteger.__rxor__c             C   s   |   | j|> ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú
__lshift__{   s    zInteger.__lshift__c             C   s   |   | j|? ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú
__rshift__~   s    zInteger.__rshift__c             C   s   |   | j| ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__add__�   s    zInteger.__add__c             C   s   |   || j ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__radd__„   s    zInteger.__radd__c             C   s   |   | j| ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__sub__‡   s    zInteger.__sub__c             C   s   |   || j ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__rsub__Š   s    zInteger.__rsub__c             C   s   |   | j| ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__mul__�   s    zInteger.__mul__c             C   s   |   || j ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__rmul__�   s    zInteger.__rmul__c             C   s   |   | j| ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__mod__“   s    zInteger.__mod__c             C   s   |   || j ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__rmod__–   s    zInteger.__rmod__Nc             C   s   |   t| j||ƒ¡S )N)r(   Úpowr)   )r#   r$   Úmodulor&   r&   r'   Ú__pow__™   s    zInteger.__pow__c             C   s   |   t|| jƒ¡S )N)r(   r:   r)   )r#   r$   r&   r&   r'   Ú__rpow__œ   s    zInteger.__rpow__c             C   s   |   | j| ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__floordiv__Ÿ   s    zInteger.__floordiv__c             C   s   |   || j ¡S )N)r(   r)   )r#   r$   r&   r&   r'   Ú__rfloordiv__¢   s    zInteger.__rfloordiv__r   c             C   s,   t |tƒrt| j| ƒS |  | j| ¡S d S )N)Ú
isinstanceÚfloatr   r)   r(   )r#   r$   r&   r&   r'   Ú__div__¦   s    
zInteger.__div__c             C   s,   t |tƒrt|| j ƒS |  || j ¡S d S )N)r@   rA   r   r)   r(   )r#   r$   r&   r&   r'   Ú__rdiv__¬   s    
zInteger.__rdiv__c             C   s   t | j| ƒS )N)r   r)   )r#   r$   r&   r&   r'   Ú__truediv__²   s    zInteger.__truediv__c             C   s   t || j ƒS )N)r   r)   )r#   r$   r&   r&   r'   Ú__rtruediv__µ   s    zInteger.__rtruediv__c             C   s   |   t| j|ƒ¡S )N)r(   Údivmodr)   )r#   r$   r&   r&   r'   Ú
__divmod__¸   s    zInteger.__divmod__c             C   s   |   t|| jƒ¡S )N)r(   rF   r)   )r#   r$   r&   r&   r'   Ú__rdivmod__»   s    zInteger.__rdivmod__c             C   s
   t | jƒS )N)Úintr)   )r#   r&   r&   r'   Ú__int__À   s    zInteger.__int__c             C   s
   t | jƒS )N)Úlongr)   )r#   r&   r&   r'   Ú__long__Ä   s    zInteger.__long__c             C   s
   t | jƒS )N)rA   r)   )r#   r&   r&   r'   Ú	__float__Ç   s    zInteger.__float__c             C   s   |   t| jƒ¡S )N)r(   Úabsr)   )r#   r&   r&   r'   Ú__abs__Ê   s    zInteger.__abs__c             C   s
   t | jƒS )N)rI   r)   )r#   r&   r&   r'   Ú	__index__Í   s    zInteger.__index__c             C   s   |   | j
 ¡S )N)r(   r)   )r#   r&   r&   r'   Ú__pos__Ð   s    zInteger.__pos__c             C   s   |   | j ¡S )N)r(   r)   )r#   r&   r&   r'   Ú__neg__Ó   s    zInteger.__neg__c             C   s   |   | j ¡S )N)r(   r)   )r#   r&   r&   r'   Ú
__invert__Ö   s    zInteger.__invert__c             C   s"   t | j|ƒ}|r|  |¡S |S d S )N)Úroundr)   r(   )r#   ÚnÚrr&   r&   r'   Ú	__round__Ù   s    
zInteger.__round__c             C   s   t  | j¡S )N)ÚmathÚfloorr)   )r#   r&   r&   r'   Ú	__floor__à   s    zInteger.__floor__c             C   s   t  | j¡S )N)rX   Úceilr)   )r#   r&   r&   r'   Ú__ceil__ã   s    zInteger.__ceil__)r   é   c             C   s   |   t | j¡¡S )N)r(   rX   Útruncr)   )r#   r&   r&   r'   Ú	__trunc__ç   s    zInteger.__trunc__c             C   s
   | j |k S )N)r)   )r#   r$   r&   r&   r'   Ú__lt__ê   s    zInteger.__lt__c             C   s
   | j |kS )N)r)   )r#   r$   r&   r&   r'   Ú__le__í   s    zInteger.__le__c             C   s
   | j |kS )N)r)   )r#   r$   r&   r&   r'   Ú__eq__ð   s    zInteger.__eq__c             C   s
   | j |kS )N)r)   )r#   r$   r&   r&   r'   Ú__ne__ó   s    zInteger.__ne__c             C   s
   | j |kS )N)r)   )r#   r$   r&   r&   r'   Ú__gt__ö   s    zInteger.__gt__c             C   s
   | j |kS )N)r)   )r#   r$   r&   r&   r'   Ú__ge__ù   s    zInteger.__ge__c             C   s\   yt |ƒS  tk
rV   y
| j| S  tk
rP   t d|t ¡ d f ¡‚Y nX Y nX d S )Nz Can't coerce %r into integer: %sé   )rI   Ú
ValueErrorr    ÚKeyErrorr   ÚPyAsn1ErrorÚsysÚexc_info)r#   r$   r&   r&   r'   ÚprettyInü   s    
zInteger.prettyInc             C   s,   yt | j| ƒS  tk
r&   t |ƒS X d S )N)Ústrr    rh   )r#   r$   r&   r&   r'   Ú	prettyOut	  s    zInteger.prettyOutc             C   s   | j S )N)r    )r#   r&   r&   r'   ÚgetNamedValues  s    zInteger.getNamedValues)N)r   )HÚ__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú
initTagSetÚTagÚtagClassUniversalÚtagFormatSimpleÚtagSetr   ÚConstraintsIntersectionÚsubtypeSpecr
   ÚNamedValuesr    r   r!   Ú	getTypeIdÚtypeIdr   r"   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r<   r=   r>   r?   rj   Úversion_inforB   rC   rD   rE   rG   rH   Ú__hash__rJ   rL   rM   rO   rP   rQ   rR   rS   rW   rZ   r\   r_   r`   ra   rb   rc   rd   re   rl   rn   ro   r&   r&   r&   r'   r   "   st   -



	c               @   sN   e Zd ZdZe e ejejd¡¡Z	e
je dd¡ Ze dd¡Ze
 ¡ ZdS )r   aW  Create |ASN.1| type or object.

    |ASN.1| objects are immutable and duck-type Python :class:`int` objects.

    Keyword Args
    ------------
    value: :class:`int`, :class:`str` or |ASN.1| object
        Python integer or boolean or string literal or |ASN.1| class instance.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
        Object representing non-default symbolic aliases for numbers

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------
    .. code-block:: python

        class RoundResult(Boolean):
            '''
            ASN.1 specification:

            RoundResult ::= BOOLEAN

            ok RoundResult ::= TRUE
            ko RoundResult ::= FALSE
            '''
        ok = RoundResult(True)
        ko = RoundResult(False)
    rf   r   )ÚFalser   )ÚTruerf   N)rp   rq   rr   rs   r   rt   ru   rv   rw   rx   r   rz   r   ÚSingleValueConstraintr
   r{   r    r|   r}   r&   r&   r&   r'   r     s   'é   c               @   s$   e Zd Zd ZZdd„ Zdd„ ZdS )ÚSizedIntegerNc             C   s    || _ t|t  | ¡ dƒ| _| S )Nr   )Ú	bitLengthÚmaxr   ÚleadingZeroBits)r#   r…   r&   r&   r'   ÚsetBitLengthZ  s    zSizedInteger.setBitLengthc             C   s    | j d kr|  t  | ¡¡ | j S )N)r…   rˆ   r   )r#   r&   r&   r'   Ú__len___  s    
zSizedInteger.__len__)rp   rq   rr   r…   r‡   rˆ   r‰   r&   r&   r&   r'   r„   W  s   r„   c               @   sX  e Zd ZdZe e ejejd¡¡Z	e
 ¡ Ze ¡ Zej ¡ Ze ZZefdd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z dd„ Z!dd„ Z"dd„ Z#dd„ Z$dd „ Z%d!d"„ Z&d#d$„ Z'd%d&„ Z(d'd(„ Z)d)d*„ Z*e+j,d+ dk �rd,d-„ Z-d.d/„ Z.d0d1„ Z/d2d3„ Z0d4d5„ Z1e2d@d8d9„ƒZ3e2dAd:d;„ƒZ4e2dBd<d=„ƒZ5d>d?„ Z6d7S )Cr   a²  Create |ASN.1| schema or value object.

    |ASN.1| objects are immutable and duck-type both Python :class:`tuple` (as a tuple
    of bits) and :class:`int` objects.

    Keyword Args
    ------------
    value: :class:`int`, :class:`str` or |ASN.1| object
        Python integer or string literal representing binary or hexadecimal
        number or sequence of integer bits or |ASN.1| object.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
        Object representing non-default symbolic aliases for numbers

    binValue: :py:class:`str`
        Binary string initializer to use instead of the *value*.
        Example: '10110011'.

    hexValue: :py:class:`str`
        Hexadecimal string initializer to use instead of the *value*.
        Example: 'DEADBEEF'.

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------
    .. code-block:: python

        class Rights(BitString):
            '''
            ASN.1 specification:

            Rights ::= BIT STRING { user-read(0), user-write(1),
                                    group-read(2), group-write(3),
                                    other-read(4), other-write(5) }

            group1 Rights ::= { group-read, group-write }
            group2 Rights ::= '0011'B
            group3 Rights ::= '3'H
            '''
            namedValues = NamedValues(
                ('user-read', 0), ('user-write', 1),
                ('group-read', 2), ('group-write', 3),
                ('other-read', 4), ('other-write', 5)
            )

        group1 = Rights(('group-read', 'group-write'))
        group2 = Rights('0011')
        group3 = Rights(0x3)
    rƒ   c             K   sÎ   |t krh|rhy| j| d¡dd�}W n tk
r8   Y nX y| j| d¡dd�}W n tk
rf   Y nX |t kr¦| jt k	rŒ| j| jdd�}n| jt k	r¦| j| jdd�}d|kr¸| j|d< tj	j
| |f|Ž d S )NÚbinValueT)ÚinternalFormatÚhexValuer    )r   ÚfromBinaryStringÚpoprh   ÚfromHexStringÚdefaultBinValueÚdefaultHexValuer    r   r!   r"   )r#   r$   r%   r&   r&   r'   r"   ·  s$    


zBitString.__init__c             C   s   |   ¡ S )N)ÚasBinary)r#   r&   r&   r'   Ú__str__Ò  s    zBitString.__str__c             C   s.   |   |¡}| |kp,| j|ko,t| jƒt|ƒkS )N)rl   r)   Úlen)r#   Úotherr&   r&   r'   rb   Õ  s    
zBitString.__eq__c             C   s&   |   |¡}| j|kp$t| jƒt|ƒkS )N)rl   r)   r”   )r#   r•   r&   r&   r'   rc   Ù  s    
zBitString.__ne__c             C   s8   |   |¡}t| jƒt|ƒk p6t| jƒt|ƒko6| j|k S )N)rl   r”   r)   )r#   r•   r&   r&   r'   r`   Ý  s    
zBitString.__lt__c             C   s8   |   |¡}t| jƒt|ƒkp6t| jƒt|ƒko6| j|kS )N)rl   r”   r)   )r#   r•   r&   r&   r'   ra   á  s    
zBitString.__le__c             C   s8   |   |¡}t| jƒt|ƒkp6t| jƒt|ƒko6| j|kS )N)rl   r”   r)   )r#   r•   r&   r&   r'   rd   å  s    
zBitString.__gt__c             C   s8   |   |¡}t| jƒt|ƒkp6t| jƒt|ƒko6| j|kS )N)rl   r”   r)   )r#   r•   r&   r&   r'   re   é  s    
zBitString.__ge__c             C   s
   t | jƒS )N)r”   r)   )r#   r&   r&   r'   r‰   ï  s    zBitString.__len__c                sl   |j tkr0ˆ  ‡ fdd„t| tˆ ƒ¡Ž D ƒ¡S tˆ jƒd }||ksN|dk rVtdƒ‚ˆ j|| ? d@ S d S )Nc                s   g | ]}ˆ | ‘qS r&   r&   )Ú.0Úx)r#   r&   r'   ú
<listcomp>ô  s    z)BitString.__getitem__.<locals>.<listcomp>rf   r   zbit index out of range)Ú	__class__Úslicer(   ÚrangeÚindicesr”   r)   Ú
IndexError)r#   ÚiÚlengthr&   )r#   r'   Ú__getitem__ò  s    
&zBitString.__getitem__c             c   s0   t | jƒ}x |r*|d8 }| j|? d@ V  qW d S )Nrf   )r”   r)   )r#   rŸ   r&   r&   r'   Ú__iter__û  s    
zBitString.__iter__c             C   s   t t| ƒƒS )N)ÚreversedÚtuple)r#   r&   r&   r'   Ú__reversed__  s    zBitString.__reversed__c             C   s:   |   |¡}|  t| jt|ƒ> |B ƒ t| jƒt|ƒ ¡¡S )N)rl   r(   r„   r)   r”   rˆ   )r#   r$   r&   r&   r'   r2     s    
zBitString.__add__c             C   s<   |   |¡}|  t|t| jƒ> | jB ƒ t| jƒt|ƒ ¡¡S )N)rl   r(   r„   r”   r)   rˆ   )r#   r$   r&   r&   r'   r3   
  s    
zBitString.__radd__c             C   s>   | j }x,|dkr2|t| j ƒK }|| j O }|d8 }qW |  |¡S )Nrf   )r)   r”   r(   )r#   r$   Z	bitStringr&   r&   r'   r6     s    

zBitString.__mul__c             C   s   | | S )Nr&   )r#   r$   r&   r&   r'   r7     s    zBitString.__rmul__c             C   s$   |   t| j|> ƒ t| jƒ| ¡¡S )N)r(   r„   r)   rˆ   r”   )r#   Úcountr&   r&   r'   r0     s    zBitString.__lshift__c             C   s*   |   t| j|? ƒ tdt| jƒ| ƒ¡¡S )Nr   )r(   r„   r)   rˆ   r†   r”   )r#   r¥   r&   r&   r'   r1     s    zBitString.__rshift__c             C   s   | j S )N)r)   )r#   r&   r&   r'   rJ     s    zBitString.__int__c             C   s
   t | jƒS )N)rA   r)   )r#   r&   r&   r'   rM   "  s    zBitString.__float__r   c             C   s   | j S )N)r)   )r#   r&   r&   r'   rL   &  s    zBitString.__long__c             C   s   t t |  ¡ ¡ƒS )z¤Get |ASN.1| value as a sequence of 8-bit integers.

        If |ASN.1| object length is not a multiple of 8, result
        will be left-padded with zeros.
        )r£   r   Z	octs2intsÚasOctets)r#   r&   r&   r'   Ú	asNumbers)  s    zBitString.asNumbersc             C   s   t j| jt| ƒd�S )zœGet |ASN.1| value as a sequence of octets.

        If |ASN.1| object length is not a multiple of 8, result
        will be left-padded with zeros.
        )rŸ   )r   Úto_bytesr)   r”   )r#   r&   r&   r'   r¦   1  s    zBitString.asOctetsc             C   s   | j S )z5Get |ASN.1| value as a single integer value.
        )r)   )r#   r&   r&   r'   Ú	asInteger9  s    zBitString.asIntegerc             C   s.   t  | j¡dd… }dt| jƒt|ƒ  | S )z4Get |ASN.1| value as a text string of bits.
        r   NÚ0)r   Úbinr)   r”   )r#   Z	binStringr&   r&   r'   r’   >  s    zBitString.asBinaryFNc          	   C   s�   yt |dƒ t|ƒd ¡}W n0 tk
rL   t d| jt ¡ d f ¡‚Y nX |dk	r€t t |ƒt|ƒ> |B ƒ t|ƒt|ƒ ¡}|sŒ| |ƒ}|S )z¬Create a |ASN.1| object initialized from the hex string.

        Parameters
        ----------
        value: :class:`str`
            Text string like 'DEADBEEF'
        é   é   z%s.fromHexString() error: %srf   N)	r„   rˆ   r”   rg   r   ri   rp   rj   rk   )Úclsr$   r‹   Úprependr&   r&   r'   r�   D  s    	"zBitString.fromHexStringc          	   C   s�   yt |p
ddƒ t|ƒ¡}W n0 tk
rL   t d| jt ¡ d f ¡‚Y nX |dk	r€t t |ƒt|ƒ> |B ƒ t|ƒt|ƒ ¡}|sŒ| |ƒ}|S )z´Create a |ASN.1| object initialized from a string of '0' and '1'.

        Parameters
        ----------
        value: :class:`str`
            Text string like '1010111'
        rª   r   z%s.fromBinaryString() error: %srf   N)	r„   rˆ   r”   rg   r   ri   rp   rj   rk   )r®   r$   r‹   r¯   r&   r&   r'   r�   ]  s    	"zBitString.fromBinaryStringc             C   sf   t t |¡|? ƒ t|ƒd | ¡}|dk	rVt t |ƒt|ƒ> |B ƒ t|ƒt|ƒ ¡}|sb| |ƒ}|S )zãCreate a |ASN.1| object initialized from a string.

        Parameters
        ----------
        value: :class:`str` (Py2) or :class:`bytes` (Py3)
            Text string like '\\x01\\xff' (Py2) or b'\\x01\\xff' (Py3)
        é   N)r„   r   Ú
from_bytesrˆ   r”   )r®   r$   r‹   r¯   Úpaddingr&   r&   r'   ÚfromOctetStringv  s    	$zBitString.fromOctetStringc                s   t |tƒr|S t |¡�rŒ|s,tdƒ d¡S |d dkr–|dd … dkr^ˆ j|dd… dd�S |dd … dkr„ˆ j|dd… dd�S t d	|f ¡‚nôˆ j	�r8| 
¡ �s8d
d„ | d¡D ƒ}y‡ fdd„|D ƒ}W n& tk
� rø   t d|f ¡‚Y nX t|ƒ}d}x|D ]}|d|| > O }�qW t|ƒ |d ¡S | d¡�rZˆ j|dd … dd�S | d¡�r|ˆ j|dd … dd�S ˆ j|dd�S npt |ttfƒ�rºˆ jd dd„ |D ƒ¡dd�S t |tƒ�rØt|ƒ t|ƒ¡S t |tƒ�rìt|ƒS t d|f ¡‚d S )Nr   ú'éþÿÿÿz'Brf   T)r‹   z'Hz Bad BIT STRING value notation %sc             S   s   g | ]}|  ¡ ‘qS r&   )Ústrip)r–   r—   r&   r&   r'   r˜   �  s    z&BitString.prettyIn.<locals>.<listcomp>ú,c                s   g | ]}ˆ j | ‘qS r&   )r    )r–   Úname)r#   r&   r'   r˜   ¡  s    zunknown bit name(s) in %rÚ0xr   Ú0bÚ c             S   s   g | ]}|rd pd‘qS )Ú1rª   r&   )r–   Úbr&   r&   r'   r˜   ¸  s    z#Bad BitString initializer type '%s')r@   r„   r   ÚisStringTyperˆ   r�   r�   r   ri   r    ÚisdigitÚsplitrh   r†   Ú
startswithr£   ÚlistÚjoinr   r”   ÚintTypes)r#   r$   ÚnamesZbitPositionsZrightmostPositionÚnumberZbitPositionr&   )r#   r'   rl   ‹  sH    

zBitString.prettyIn)FN)FN)FNr   )7rp   rq   rr   rs   r   rt   ru   rv   rw   rx   r   ry   rz   r
   r{   r    r   r!   r|   r}   r   r�   r‘   r"   r“   rb   rc   r`   ra   rd   re   r‰   r    r¡   r¤   r2   r3   r6   r7   r0   r1   rJ   rM   rj   r~   rL   r§   r¦   r©   r’   Úclassmethodr�   r�   r³   rl   r&   r&   r&   r'   r   f  sP   ;
	c             C   s   x| D ]}|sdS qW dS )NFTr&   )ÚiterableÚelementr&   r&   r'   ÚallÌ  s    
rÊ   c               @   s4  e Zd ZdZe e ejejd¡¡Z	e
 ¡ Zej ¡ Ze ZZdZefdd„Zejd dkr†dd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zn(dd	„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd7dd„Ze dd„ ƒZ!e dd„ ƒZ"d d!„ Z#d"d#„ Z$d$d%„ Z%d&d'„ Z&d(d)„ Z'd*d+„ Z(d,d-„ Z)d.d/„ Z*d0d1„ Z+d2d3„ Z,d4d5„ Z-d6S )8r   aè  Create |ASN.1| schema or value object.

    |ASN.1| objects are immutable and duck-type Python 2 :class:`str` or Python 3 :class:`bytes`.
    When used in Unicode context, |ASN.1| type assumes "|encoding|" serialisation.

    Keyword Args
    ------------
    value: :class:`str`, :class:`bytes` or |ASN.1| object
        string (Python 2) or bytes (Python 3), alternatively unicode object
        (Python 2) or string (Python 3) representing character string to be
        serialised into octets (note `encoding` parameter) or |ASN.1| object.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    encoding: :py:class:`str`
        Unicode codec ID to encode/decode :class:`unicode` (Python 2) or
        :class:`str` (Python 3) the payload when |ASN.1| object is used
        in text string context.

    binValue: :py:class:`str`
        Binary string initializer to use instead of the *value*.
        Example: '10110011'.

    hexValue: :py:class:`str`
        Hexadecimal string initializer to use instead of the *value*.
        Example: 'DEADBEEF'.

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------
    .. code-block:: python

        class Icon(OctetString):
            '''
            ASN.1 specification:

            Icon ::= OCTET STRING

            icon1 Icon ::= '001100010011001000110011'B
            icon2 Icon ::= '313233'H
            '''
        icon1 = Icon.fromBinaryString('001100010011001000110011')
        icon2 = Icon.fromHexString('313233')
    r­   z
iso-8859-1c             K   s¾   |r`|t kr`y|  | d¡¡}W n tk
r4   Y nX y|  | d¡¡}W n tk
r^   Y nX |t kr–| jt k	r€|  | j¡}n| jt k	r–|  | j¡}d|kr¨| j|d< tj	j
| |f|Ž d S )NrŠ   rŒ   Úencoding)r   r�   rŽ   rh   r�   r�   r‘   rË   r   r!   r"   )r#   r$   r%   r&   r&   r'   r"     s$    


zOctetString.__init__r   r   c          	   C   s°   t |tƒr|S t |tƒrTy| | j¡S  ttfk
rP   t d|| jf ¡‚Y q¬X nXt |t	t
fƒr¤yd dd„ |D ƒ¡S  tk
r    t d| jj|f ¡‚Y q¬X nt|ƒS d S )Nz&Can't encode string '%s' with codec %sr»   c             S   s   g | ]}t |ƒ‘qS r&   )Úchr)r–   r—   r&   r&   r'   r˜   B  s    z(OctetString.prettyIn.<locals>.<listcomp>zBad %s initializer '%s')r@   rm   ÚunicodeÚencoderË   ÚLookupErrorÚUnicodeEncodeErrorr   ri   r£   rÂ   rÃ   rg   r™   rp   )r#   r$   r&   r&   r'   rl   6  s    

zOctetString.prettyInc             C   s
   t | jƒS )N)rm   r)   )r#   r&   r&   r'   r“   J  s    zOctetString.__str__c             C   s>   y| j  | j¡S  tk
r8   t d| j | jf ¡‚Y nX d S )Nz&Can't decode string '%s' with codec %s)r)   ÚdecoderË   ÚUnicodeDecodeErrorr   ri   )r#   r&   r&   r'   Ú__unicode__M  s
    zOctetString.__unicode__c             C   s
   t | jƒS )N)rm   r)   )r#   r&   r&   r'   r¦   V  s    zOctetString.asOctetsc             C   s   t dd„ | jD ƒƒS )Nc             S   s   g | ]}t |ƒ‘qS r&   )Úord)r–   r—   r&   r&   r'   r˜   Z  s    z)OctetString.asNumbers.<locals>.<listcomp>)r£   r)   )r#   r&   r&   r'   r§   Y  s    zOctetString.asNumbersc             C   s¤   t |tƒr|S t |tƒrPy| | j¡S  tk
rL   t d|| jf ¡‚Y q X nPt |tƒrb| 	¡ S t |t
jƒr||  t|ƒ¡S t |ttfƒr˜|  t|ƒ¡S t|ƒS d S )Nz(Can't encode string '%s' with '%s' codec)r@   Úbytesrm   rÎ   rË   rÐ   r   ri   r   r¦   r   r!   rl   r£   rÂ   )r#   r$   r&   r&   r'   rl   ]  s    


c          	   C   sD   y| j  | j¡S  tk
r>   t d| j | j| jjf ¡‚Y nX d S )Nz0Can't decode string '%s' with '%s' codec at '%s')r)   rÑ   rË   rÒ   r   ri   r™   rp   )r#   r&   r&   r'   r“   p  s
    c             C   s
   t | jƒS )N)rÕ   r)   )r#   r&   r&   r'   Ú	__bytes__y  s    zOctetString.__bytes__c             C   s
   t | jƒS )N)rÕ   r)   )r#   r&   r&   r'   r¦   |  s    c             C   s
   t | jƒS )N)r£   r)   )r#   r&   r&   r'   r§     s    c             C   s   |S )Nr&   )r#   r$   r&   r&   r'   rn   ”  s    zOctetString.prettyOutc             C   sf   |   | j¡}|| jk	r|S |  ¡ }x>|D ],}|dk s<|dkr(dd dd„ |D ƒ¡ S q(W t | ¡S d S )Né    é~   r¹   r»   c             s   s   | ]}d | V  qdS )z%.2xNr&   )r–   r—   r&   r&   r'   ú	<genexpr>£  s    z*OctetString.prettyPrint.<locals>.<genexpr>)rn   r)   r§   rÃ   r   r“   )r#   Úscoper$   Znumbersr—   r&   r&   r'   ÚprettyPrint—  s    

zOctetString.prettyPrintc             C   s|   d}d}g }xZ| D ]R}|r$|d8 }nd}|  |¡ d}|dkrHt|ƒ}nt d|f ¡‚|||> O }qW |  |¡ t |¡S )z´Create a |ASN.1| object initialized from a string of '0' and '1'.

        Parameters
        ----------
        value: :class:`str`
            Text string like '1010111'
        r°   r   rf   é   )rª   r¼   z&Non-binary OCTET STRING initializer %s)ÚappendrI   r   ri   r   Ú	ints2octs)r$   ZbitNoZbyterV   Úvr&   r&   r'   r�   ¨  s     	




zOctetString.fromBinaryStringc             C   sZ   g }g }x.| D ]&}|r0|  t|| dƒ¡ d}q|}qW |rP|  t|d dƒ¡ t |¡S )z¬Create a |ASN.1| object initialized from the hex string.

        Parameters
        ----------
        value: :class:`str`
            Text string like 'DEADBEEF'
        r¬   Nrª   )rÝ   rI   r   rÞ   )r$   rV   Úprß   r&   r&   r'   r�   Ç  s    	
zOctetString.fromHexStringc             C   s
   t | jƒS )N)r”   r)   )r#   r&   r&   r'   r‰   ß  s    zOctetString.__len__c             C   s(   |j tkr|  | j| ¡S | j| S d S )N)r™   rš   r(   r)   )r#   rž   r&   r&   r'   r    â  s    
zOctetString.__getitem__c             C   s
   t | jƒS )N)Úiterr)   )r#   r&   r&   r'   r¡   è  s    zOctetString.__iter__c             C   s
   || j kS )N)r)   )r#   r$   r&   r&   r'   Ú__contains__ë  s    zOctetString.__contains__c             C   s   |   | j|  |¡ ¡S )N)r(   r)   rl   )r#   r$   r&   r&   r'   r2   î  s    zOctetString.__add__c             C   s   |   |  |¡| j ¡S )N)r(   rl   r)   )r#   r$   r&   r&   r'   r3   ñ  s    zOctetString.__radd__c             C   s   |   | j| ¡S )N)r(   r)   )r#   r$   r&   r&   r'   r6   ô  s    zOctetString.__mul__c             C   s   | | S )Nr&   )r#   r$   r&   r&   r'   r7   ÷  s    zOctetString.__rmul__c             C   s
   t | jƒS )N)rI   r)   )r#   r&   r&   r'   rJ   ú  s    zOctetString.__int__c             C   s
   t | jƒS )N)rA   r)   )r#   r&   r&   r'   rM   ý  s    zOctetString.__float__c             C   s
   t | jƒS )N)r¢   r)   )r#   r&   r&   r'   r¤      s    zOctetString.__reversed__N)r   ).rp   rq   rr   rs   r   rt   ru   rv   rw   rx   r   ry   rz   r   r!   r|   r}   r   r�   r‘   rË   r"   rj   r~   rl   r“   rÓ   r¦   r§   rÖ   rn   rÛ   Ústaticmethodr�   r�   r‰   r    r¡   râ   r2   r3   r6   r7   rJ   rM   r¤   r&   r&   r&   r'   r   Ó  sD   4
	
	
c               @   sN   e Zd ZdZe e ejejd¡¡Z	e
je e d¡¡ Ze
 ¡ Zdd„ ZdS )r   aØ  Create |ASN.1| schema or value object.

    |ASN.1| objects are immutable and duck-type Python :class:`str` objects (always empty).

    Keyword Args
    ------------
    value: :class:`str` or :py:class:`~pyasn1.type.univ.Null` object
        Python empty string literal or any object that evaluates to `False`

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------
    .. code-block:: python

        class Ack(Null):
            '''
            ASN.1 specification:

            Ack ::= NULL
            '''
        ack = Ack('')
    r]   r»   c             C   s   |r|S t  d¡S )Nr»   )r   Ústr2octs)r#   r$   r&   r&   r'   rl   .  s    zNull.prettyInN)rp   rq   rr   rs   r   rt   ru   rv   rw   rx   r   rz   r   r‚   r   rä   r|   r}   rl   r&   r&   r&   r'   r     s   r   c               @   s’   e Zd ZdZe e ejejd¡¡Z	e
 ¡ Zej ¡ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r   a%  Create |ASN.1| schema or value object.

    |ASN.1| objects are immutable and duck-type Python :class:`tuple` objects (tuple of non-negative integers).

    Keyword Args
    ------------
    value: :class:`tuple`, :class:`str` or |ASN.1| object
        Python sequence of :class:`int` or string literal or |ASN.1| object.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------
    .. code-block:: python

        class ID(ObjectIdentifier):
            '''
            ASN.1 specification:

            ID ::= OBJECT IDENTIFIER

            id-edims ID ::= { joint-iso-itu-t mhs-motif(6) edims(7) }
            id-bp ID ::= { id-edims 11 }
            '''
        id_edims = ID('2.6.7')
        id_bp = id_edims + (11,)
    é   c             C   s   |   | j| ¡S )N)r(   r)   )r#   r•   r&   r&   r'   r2   p  s    zObjectIdentifier.__add__c             C   s   |   || j ¡S )N)r(   r)   )r#   r•   r&   r&   r'   r3   s  s    zObjectIdentifier.__radd__c             C   s   | j S )N)r)   )r#   r&   r&   r'   ÚasTuplev  s    zObjectIdentifier.asTuplec             C   s
   t | jƒS )N)r”   r)   )r#   r&   r&   r'   r‰   {  s    zObjectIdentifier.__len__c             C   s(   |j tkr|  | j| ¡S | j| S d S )N)r™   rš   r(   r)   )r#   rž   r&   r&   r'   r    ~  s    
zObjectIdentifier.__getitem__c             C   s
   t | jƒS )N)rá   r)   )r#   r&   r&   r'   r¡   „  s    zObjectIdentifier.__iter__c             C   s
   || j kS )N)r)   )r#   r$   r&   r&   r'   râ   ‡  s    zObjectIdentifier.__contains__c             C   s   | j  |¡S )N)r)   Úindex)r#   Zsuboidr&   r&   r'   rç   Š  s    zObjectIdentifier.indexc             C   s6   t | ƒ}|t |ƒkr2| jd|… |d|… kr2dS dS )av  Indicate if this |ASN.1| object is a prefix of other |ASN.1| object.

        Parameters
        ----------
        other: |ASN.1| object
            |ASN.1| object

        Returns
        -------
        : :class:`bool`
            :class:`True` if this |ASN.1| object is a parent (e.g. prefix) of the other |ASN.1| object
            or :class:`False` otherwise.
        NTF)r”   r)   )r#   r•   Úlr&   r&   r'   Ú
isPrefixOf�  s
    zObjectIdentifier.isPrefixOfc          
   C   s  t |tƒrt|ƒS t |¡r’d|krDt d|| jjt	 
¡ d f ¡‚ytdd„ | d¡D ƒƒS  tk
r�   t d|| jjt	 
¡ d f ¡‚Y nX ytdd„ |D ƒƒ}W n8 ttfk
rà   t d|| jjt	 
¡ d f ¡‚Y nX t|ƒt|ƒkrö|S t d|| jjf ¡‚d S )	Nú-z Malformed Object ID %s at %s: %srf   c             S   s   g | ]}|rt |ƒ‘qS r&   )rI   )r–   ÚsubOidr&   r&   r'   r˜   ª  s    z-ObjectIdentifier.prettyIn.<locals>.<listcomp>Ú.c             S   s   g | ]}|d krt |ƒ‘qS )r   )rI   )r–   rë   r&   r&   r'   r˜   ±  s    zMalformed Object ID %s at %s)r@   r   r£   r   r¾   r   ri   r™   rp   rj   rk   rÀ   rg   Ú	TypeErrorr”   )r#   r$   ZtupleOfIntsr&   r&   r'   rl   ¡  s&    

""zObjectIdentifier.prettyInc             C   s   d  dd„ |D ƒ¡S )Nrì   c             S   s   g | ]}t |ƒ‘qS r&   )rm   )r–   r—   r&   r&   r'   r˜   ¾  s    z.ObjectIdentifier.prettyOut.<locals>.<listcomp>)rÃ   )r#   r$   r&   r&   r'   rn   ½  s    zObjectIdentifier.prettyOutN)rp   rq   rr   rs   r   rt   ru   rv   rw   rx   r   ry   rz   r   r!   r|   r}   r2   r3   ræ   r‰   r    r¡   râ   rç   ré   rl   rn   r&   r&   r&   r'   r   <  s    $
c               @   sB  e Zd ZdZdZyedƒZedƒZeefZW n  e	k
rL   d ZZdZY nX e
 e
 e
je
jd¡¡Ze ¡ Zej ¡ Zedd„ ƒZd	d
„ Zdbdd„Zedd„ ƒZedd„ ƒZedd„ ƒZdd„ Zdd„ Z dd„ Z!dd„ Z"dd„ Z#dd„ Z$d d!„ Z%d"d#„ Z&dcd$d%„Z'd&d'„ Z(e)j*d d(k�r.d)d*„ Z+d+d,„ Z,n d-d.„ Z-d/d0„ Z.d1d2„ Z/d3d4„ Z0d5d6„ Z1e)j*d d(k�rnd7d8„ Z2d9d:„ Z3d;d<„ Z4d=d>„ Z5d?d@„ Z6dddAdB„Z7dCdD„ Z8dEdF„ Z9e)j*dd(… dGk�rÄdHdI„ Z:dJdK„ Z;dLdM„ Z<dNdO„ Z=dPdQ„ Z>dRdS„ Z?dTdU„ Z@e)j*d d(k�rdVdW„ ZAndXdY„ ZBejjCZCdZd[„ ZDd\d]„ ZEd^d_„ ZFd`da„ ZGdS )er   aZ  Create |ASN.1| schema or value object.

    |ASN.1| objects are immutable and duck-type Python :class:`float` objects.
    Additionally, |ASN.1| objects behave like a :class:`tuple` in which case its
    elements are mantissa, base and exponent.

    Keyword Args
    ------------
    value: :class:`tuple`, :class:`float` or |ASN.1| object
        Python sequence of :class:`int` (representing mantissa, base and
        exponent) or float instance or *Real* class instance.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------
    .. code-block:: python

        class Pi(Real):
            '''
            ASN.1 specification:

            Pi ::= REAL

            pi Pi ::= { mantissa 314159, base 10, exponent -5 }

            '''
        pi = Pi((314159, 10, -5))
    NÚinfz-infr&   é	   c             C   s:   | \}}}x$|r.|d dkr.|d }|d7 }qW |||fS )Né
   r   rf   r&   )r$   Úmr½   Úer&   r&   r'   Z__normalizeBase10  s
    
zReal.__normalizeBase10c             C   s¤  t |tƒr´t|ƒdkr´t |d tƒr@t |d tƒr@t |d tƒsPt d|f ¡‚t |d tƒrz| jrz|d | jkrz|d S |d dkršt d|d f ¡‚|d dkr°|  	|¡}|S t |tƒrÎ|  	|ddf¡S t |tƒsät
 |¡�r|t
 |¡�r$yt|ƒ}W n& tk
�r"   t d	|f ¡‚Y nX | j�r<|| jk�r<|S d}x$t|ƒ|k�rd|d9 }|d8 }�qBW |  	t|ƒd|f¡S nt |tƒ�r�t|ƒS t d	|f ¡‚d S )
Nrƒ   r   rf   r   zLame Real value syntax: %s)r   rð   z"Prohibited base for Real value: %srð   zBad real value syntax: %s)r@   r£   r”   ÚnumericTypesrÄ   r   ri   rA   Ú_infÚ_Real__normalizeBase10r   r¾   rg   rI   r   )r#   r$   rò   r&   r&   r'   rl     sD    

zReal.prettyInr   c             C   s(   y|   t| ƒ¡S  tk
r"   dS X d S )Nz
<overflow>)rn   rA   ÚOverflowError)r#   rÚ   r&   r&   r'   rÛ   3  s    zReal.prettyPrintc             C   s   | j | jkS )zÔIndicate PLUS-INFINITY object value

        Returns
        -------
        : :class:`bool`
            :class:`True` if calling object represents plus infinity
            or :class:`False` otherwise.

        )r)   Ú_plusInf)r#   r&   r&   r'   Ú	isPlusInf:  s    zReal.isPlusInfc             C   s   | j | jkS )zÕIndicate MINUS-INFINITY object value

        Returns
        -------
        : :class:`bool`
            :class:`True` if calling object represents minus infinity
            or :class:`False` otherwise.
        )r)   Ú	_minusInf)r#   r&   r&   r'   Ú
isMinusInfG  s    
zReal.isMinusInfc             C   s   | j | jkS )N)r)   rô   )r#   r&   r&   r'   ÚisInfS  s    z
Real.isInfc             C   s   |   t| ƒ| ¡S )N)r(   rA   )r#   r$   r&   r&   r'   r2   W  s    zReal.__add__c             C   s   | | S )Nr&   )r#   r$   r&   r&   r'   r3   Z  s    zReal.__radd__c             C   s   |   t| ƒ| ¡S )N)r(   rA   )r#   r$   r&   r&   r'   r6   ]  s    zReal.__mul__c             C   s   | | S )Nr&   )r#   r$   r&   r&   r'   r7   `  s    zReal.__rmul__c             C   s   |   t| ƒ| ¡S )N)r(   rA   )r#   r$   r&   r&   r'   r4   c  s    zReal.__sub__c             C   s   |   |t| ƒ ¡S )N)r(   rA   )r#   r$   r&   r&   r'   r5   f  s    zReal.__rsub__c             C   s   |   t| ƒ| ¡S )N)r(   rA   )r#   r$   r&   r&   r'   r8   i  s    zReal.__mod__c             C   s   |   |t| ƒ ¡S )N)r(   rA   )r#   r$   r&   r&   r'   r9   l  s    zReal.__rmod__c             C   s   |   tt| ƒ||ƒ¡S )N)r(   r:   rA   )r#   r$   r;   r&   r&   r'   r<   o  s    zReal.__pow__c             C   s   |   t|t| ƒƒ¡S )N)r(   r:   rA   )r#   r$   r&   r&   r'   r=   r  s    zReal.__rpow__r   c             C   s   |   t| ƒ| ¡S )N)r(   rA   )r#   r$   r&   r&   r'   rB   v  s    zReal.__div__c             C   s   |   |t| ƒ ¡S )N)r(   rA   )r#   r$   r&   r&   r'   rC   y  s    zReal.__rdiv__c             C   s   |   t| ƒ| ¡S )N)r(   rA   )r#   r$   r&   r&   r'   rD   |  s    zReal.__truediv__c             C   s   |   |t| ƒ ¡S )N)r(   rA   )r#   r$   r&   r&   r'   rE     s    zReal.__rtruediv__c             C   s   |   t| ƒ| ¡S )N)r(   rA   )r#   r$   r&   r&   r'   rG   ‚  s    zReal.__divmod__c             C   s   |   |t| ƒ ¡S )N)r(   rA   )r#   r$   r&   r&   r'   rH   …  s    zReal.__rdivmod__c             C   s   t t| ƒƒS )N)rI   rA   )r#   r&   r&   r'   rJ   ˆ  s    zReal.__int__c             C   s   t t| ƒƒS )N)rK   rA   )r#   r&   r&   r'   rL   Œ  s    zReal.__long__c             C   s:   | j | jkr| j S t| j d t| j d | j d ƒ ƒS d S )Nr   rf   r   )r)   rô   rA   r:   )r#   r&   r&   r'   rM   �  s    zReal.__float__c             C   s   |   tt| ƒƒ¡S )N)r(   rN   rA   )r#   r&   r&   r'   rO   —  s    zReal.__abs__c             C   s   |   t| ƒ
 ¡S )N)r(   rA   )r#   r&   r&   r'   rQ   š  s    zReal.__pos__c             C   s   |   t| ƒ ¡S )N)r(   rA   )r#   r&   r&   r'   rR   �  s    zReal.__neg__c             C   s$   t t| ƒ|ƒ}|r|  |¡S |S d S )N)rT   rA   r(   )r#   rU   rV   r&   r&   r'   rW      s    
zReal.__round__c             C   s   |   t t| ƒ¡¡S )N)r(   rX   rY   rA   )r#   r&   r&   r'   rZ   §  s    zReal.__floor__c             C   s   |   t t| ƒ¡¡S )N)r(   rX   r[   rA   )r#   r&   r&   r'   r\   ª  s    zReal.__ceil__)r   r]   c             C   s   |   t t| ƒ¡¡S )N)r(   rX   r^   rA   )r#   r&   r&   r'   r_   ®  s    zReal.__trunc__c             C   s   t | ƒ|k S )N)rA   )r#   r$   r&   r&   r'   r`   ±  s    zReal.__lt__c             C   s   t | ƒ|kS )N)rA   )r#   r$   r&   r&   r'   ra   ´  s    zReal.__le__c             C   s   t | ƒ|kS )N)rA   )r#   r$   r&   r&   r'   rb   ·  s    zReal.__eq__c             C   s   t | ƒ|kS )N)rA   )r#   r$   r&   r&   r'   rc   º  s    zReal.__ne__c             C   s   t | ƒ|kS )N)rA   )r#   r$   r&   r&   r'   rd   ½  s    zReal.__gt__c             C   s   t | ƒ|kS )N)rA   )r#   r$   r&   r&   r'   re   À  s    zReal.__ge__c             C   s   t t| ƒƒS )N)ÚboolrA   )r#   r&   r&   r'   Ú__nonzero__Ä  s    zReal.__nonzero__c             C   s   t t| ƒƒS )N)rü   rA   )r#   r&   r&   r'   Ú__bool__Ç  s    zReal.__bool__c             C   s&   | j | jkrt d¡‚n
| j | S d S )Nz Invalid infinite value operation)r)   rô   r   ri   )r#   Úidxr&   r&   r'   r    Ì  s    zReal.__getitem__c             C   s   | j S )N)rø   )r#   r&   r&   r'   ÚisPlusInfinityÔ  s    zReal.isPlusInfinityc             C   s   | j S )N)rú   )r#   r&   r&   r'   ÚisMinusInfinity×  s    zReal.isMinusInfinityc             C   s   | j S )N)rû   )r#   r&   r&   r'   Ú
isInfinityÚ  s    zReal.isInfinity)r   )N)r   )Hrp   rq   rr   rs   Z
binEncBaserA   r÷   rù   rô   rg   r   rt   ru   rv   rw   rx   r   ry   rz   r   r!   r|   r}   rã   rõ   rl   rÛ   Úpropertyrø   rú   rû   r2   r3   r6   r7   r4   r5   r8   r9   r<   r=   rj   r~   rB   rC   rD   rE   rG   rH   rJ   rL   rM   rO   rQ   rR   rW   rZ   r\   r_   r`   ra   rb   rc   rd   re   rý   rþ   r   r    r   r  r  r&   r&   r&   r'   r   Á  s|   &

(




c               @   s@   e Zd ZdZe e ejejd¡¡Z	e
 ¡ Ze ¡ Ze ¡ ZdS )r   a  Create |ASN.1| type or object.

    |ASN.1| objects are immutable and duck-type Python :class:`int` objects.

    Keyword Args
    ------------
    value: :class:`int`, :class:`str` or |ASN.1| object
        Python integer or string literal or |ASN.1| class instance.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
        Object representing non-default symbolic aliases for numbers

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------

    .. code-block:: python

        class RadioButton(Enumerated):
            '''
            ASN.1 specification:

            RadioButton ::= ENUMERATED { button1(0), button2(1),
                                         button3(2) }

            selected-by-default RadioButton ::= button1
            '''
            namedValues = NamedValues(
                ('button1', 0), ('button2', 1),
                ('button3', 2)
            )

        selected_by_default = RadioButton('button1')
    rð   N)rp   rq   rr   rs   r   rt   ru   rv   rw   rx   r   ry   rz   r   r|   r}   r
   r{   r    r&   r&   r&   r'   r   Þ  s   ,c               @   sÀ   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
d*dd„Zdd„ Zd+dd„Zdd„ Zdd„ Zedfdd„Zedddfd d!„Zed"d#„ ƒZd,d$d%„Zd-d&d'„Zed(d)„ ƒZdS ).r   aô  Create |ASN.1| type.

    |ASN.1| objects are mutable and duck-type Python :class:`list` objects.

    Keyword Args
    ------------
    componentType : :py:class:`~pyasn1.type.base.PyAsn1Item` derivative
        A pyasn1 object representing ASN.1 type allowed within |ASN.1| type

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    sizeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing collection size constraint

    Examples
    --------

    .. code-block:: python

        class LotteryDraw(SequenceOf):  #  SetOf is similar
            '''
            ASN.1 specification:

            LotteryDraw ::= SEQUENCE OF INTEGER
            '''
            componentType = Integer()

        lotteryDraw = LotteryDraw()
        lotteryDraw.extend([123, 456, 789])
    c             O   sJ   |r6x0t d|ƒD ]"\}}||kr*t d¡‚||d< qW tjj| f|Ž d S )N)ÚcomponentTyperx   rz   ÚsizeSpecz*Conflicting positional and keyword params!r  )Úzipr   ri   r   ÚAbstractConstructedAsn1Itemr"   )r#   Úargsr%   Úkeyr$   r&   r&   r'   r"   D  s    
zSequenceOfAndSetOfBase.__init__c             C   s6   y
|   |¡S  tjk
r0   tt ¡ d ƒ‚Y nX d S )Nrf   )ÚgetComponentByPositionr   ri   r�   rj   rk   )r#   rÿ   r&   r&   r'   r    Q  s    
z"SequenceOfAndSetOfBase.__getitem__c             C   s<   y|   ||¡ W n& tjk
r6   tt ¡ d ƒ‚Y nX d S )Nrf   )ÚsetComponentByPositionr   ri   r�   rj   rk   )r#   rÿ   r$   r&   r&   r'   Ú__setitem__X  s    z"SequenceOfAndSetOfBase.__setitem__c             C   s
   g | _ d S )N)Ú_componentValues)r#   r&   r&   r'   Úclear_  s    zSequenceOfAndSetOfBase.clearc             C   s   || t | ƒ< d S )N)r”   )r#   r$   r&   r&   r'   rÝ   b  s    zSequenceOfAndSetOfBase.appendc             C   s   | j  |¡S )N)r  r¥   )r#   r$   r&   r&   r'   r¥   e  s    zSequenceOfAndSetOfBase.countc             C   s   x|D ]}|   |¡ qW d S )N)rÝ   )r#   Úvaluesr$   r&   r&   r'   Úextendh  s    
zSequenceOfAndSetOfBase.extendr   Nc             C   sL   |d krt | ƒ}y| j |||¡S  tjk
rF   tt ¡ d ƒ‚Y nX d S )Nrf   )r”   r  rç   r   ri   rg   rj   rk   )r#   r$   ÚstartÚstopr&   r&   r'   rç   l  s    zSequenceOfAndSetOfBase.indexc             C   s   | j  ¡  d S )N)r  Úreverse)r#   r&   r&   r'   r  u  s    zSequenceOfAndSetOfBase.reverseFc             C   s   | j j||d� d S )N)r	  r  )r  Úsort)r#   r	  r  r&   r&   r'   r  x  s    zSequenceOfAndSetOfBase.sortc             C   s
   t | jƒS )N)rá   r  )r#   r&   r&   r'   r¡   {  s    zSequenceOfAndSetOfBase.__iter__c             C   sV   xPt | jƒD ]B\}}|tk	rt|tjƒr>| ||j|d�¡ q| || ¡ ¡ qW d S )N)ÚcloneValueFlag)Ú	enumerater  r   r@   r   r  r  r(   )r#   ÚmyCloner  rÿ   ÚcomponentValuer&   r&   r'   Ú_cloneComponentValues~  s    z,SequenceOfAndSetOfBase._cloneComponentValuesTc             C   sZ   y| j | }W n0 tk
r>   |s&|S |  |¡ | j | }Y nX |tksN|jrR|S |S dS )a!  Return |ASN.1| type component value by position.

        Equivalent to Python sequence subscription operation (e.g. `[]`).

        Parameters
        ----------
        idx : :class:`int`
            Component index (zero-based). Must either refer to an existing
            component or to N+1 component (if *componentType* is set). In the latter
            case a new component type gets instantiated and appended to the |ASN.1|
            sequence.

        Keyword Args
        ------------
        default: :class:`object`
            If set and requested component is a schema object, return the `default`
            object instead of the requested component.

        instantiate: :class:`bool`
            If `True` (default), inner component will be automatically instantiated.
            If 'False' either existing component or the `noValue` object will be
            returned.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            Instantiate |ASN.1| component type or return existing component value

        Examples
        --------

        .. code-block:: python

            # can also be SetOf
            class MySequenceOf(SequenceOf):
                componentType = OctetString()

            s = MySequenceOf()

            # returns component #0 with `.isValue` property False
            s.getComponentByPosition(0)

            # returns None
            s.getComponentByPosition(0, default=None)

            s.clear()

            # returns noValue
            s.getComponentByPosition(0, instantiate=False)

            # sets component #0 to OctetString() ASN.1 schema
            # object and returns it
            s.getComponentByPosition(0, instantiate=True)

            # sets component #0 to ASN.1 value object
            s.setComponentByPosition(0, 'ABCD')

            # returns OctetString('ABCD') value object
            s.getComponentByPosition(0, instantiate=False)

            s.clear()

            # returns noValue
            s.getComponentByPosition(0, instantiate=False)
        N)r  r�   r  r   ÚisValue)r#   rÿ   ÚdefaultÚinstantiater  r&   r&   r'   r
  ˆ  s    B
z-SequenceOfAndSetOfBase.getComponentByPositionc             C   s°  | j }y| j| }W n0 tk
rD   t}t| jƒ|k r@t d¡‚Y nX |tkrt|dk	r`| ¡ }n|tkrrt d¡‚n¼t|t	j
ƒsØ|dk	r¢t|t	jƒr¢|j|d�}n4|tk	rÄt|t	jƒrÄ|j|d�}nt d|| f ¡‚nX|dk	�r0| j�r| |||¡�s0t d||f ¡‚n"| |||¡�s0t d||f ¡‚|�rŠ|j�rŠy|  ||¡ W n: tjk
�rˆ   t ¡ \}}	}
|d|	| jjf ƒ‚Y nX |tk�r¢| j |¡ n
|| j|< | S )aâ  Assign |ASN.1| type component by position.

        Equivalent to Python sequence item assignment operation (e.g. `[]`)
        or list.append() (when idx == len(self)).

        Parameters
        ----------
        idx: :class:`int`
            Component index (zero-based). Must either refer to existing
            component or to N+1 component. In the latter case a new component
            type gets instantiated (if *componentType* is set, or given ASN.1
            object is taken otherwise) and appended to the |ASN.1| sequence.

        Keyword Args
        ------------
        value: :class:`object` or :py:class:`~pyasn1.type.base.PyAsn1Item` derivative
            A Python value to initialize |ASN.1| component with (if *componentType* is set)
            or ASN.1 value object to assign to |ASN.1| component.

        verifyConstraints: :class:`bool`
             If `False`, skip constraints validation

        matchTags: :class:`bool`
             If `False`, skip component tags matching

        matchConstraints: :class:`bool`
             If `False`, skip component constraints matching

        Returns
        -------
        self

        Raises
        ------
        IndexError:
            When idx > len(self)
        zComponent index out of rangeNzComponent type not defined)r$   z5Non-ASN.1 value %r and undefined component type at %rz-Component value is tag-incompatible: %r vs %rz%s at %s)r  r  r�   r   r”   r   ri   r(   r@   r   ÚAsn1Itemr!   ÚstrictConstraintsÚisSameTypeWithÚisSuperTypeOfr  rz   rj   rk   r™   rp   rÝ   )r#   rÿ   r$   ÚverifyConstraintsÚ	matchTagsÚmatchConstraintsr  ÚcurrentValueÚexTypeÚexValueÚexTbr&   r&   r'   r  Ú  sD    )



z-SequenceOfAndSetOfBase.setComponentByPositionc             C   s   | j d k	r| j jS d S )N)r  ÚtagMap)r#   r&   r&   r'   ÚcomponentTagMap0  s    
z&SequenceOfAndSetOfBase.componentTagMapc             C   sf   |d7 }| j jd }xLt| jƒD ]>\}}|d| 7 }|tkrP| jd k	rP|d7 }q || |¡7 }q W |S )Nrf   z:
ú z<empty>)r™   rp   r  r  r   r  rÛ   )r#   rÚ   Úrepresentationrÿ   r  r&   r&   r'   rÛ   5  s    

z"SequenceOfAndSetOfBase.prettyPrintc             C   sX   |d7 }d| j | jjf }| jd k	r@|d| 7 }|| j |¡7 }|d d|d   d S )Nrf   z%s -> %s {
r*  Ú
Ú})rx   r™   rp   r  ÚprettyPrintType)r#   rÚ   r+  r&   r&   r'   r.  A  s    
z&SequenceOfAndSetOfBase.prettyPrintTypec             C   s&   x | j D ]}|tks|jsdS qW dS )aW  Indicate that |ASN.1| object represents ASN.1 value.

        If *isValue* is `False` then this object represents just ASN.1 schema.

        If *isValue* is `True` then, in addition to its ASN.1 schema features,
        this object can also be used like a Python built-in object (e.g. `int`,
        `str`, `dict` etc.).

        Returns
        -------
        : :class:`bool`
            :class:`False` if object represents just ASN.1 schema.
            :class:`True` if object represents ASN.1 schema and can be used as a normal value.

        Note
        ----
        There is an important distinction between PyASN1 schema and value objects.
        The PyASN1 schema objects can only participate in ASN.1 schema-related
        operations (e.g. defining or testing the structure of the data). Most
        obvious uses of ASN.1 schema is to guide serialisation codecs whilst
        encoding/decoding serialised ASN.1 contents.

        The PyASN1 value objects can **additionally** participate in many operations
        involving regular Python objects (e.g. arithmetic, comprehension etc).
        FT)r  r   r  )r#   r  r&   r&   r'   r  J  s    zSequenceOfAndSetOfBase.isValue)r   N)NF)r   )r   )rp   rq   rr   rs   r"   r    r  r  rÝ   r¥   r  rç   r  r  r¡   r  r   r
  r  r  r)  rÛ   r.  r  r&   r&   r&   r'   r   !  s,   "
	

RS

	c               @   sF   e Zd ZejZe e ejej	d¡¡Z
dZe ¡ Ze ¡ Ze ¡ ZdS )r   r¬   N)rp   rq   rr   r   rs   r   rt   ru   rv   ÚtagFormatConstructedrx   r  r   ry   rz   r  r|   r}   r&   r&   r&   r'   r   l  s   c               @   sF   e Zd ZejZe e ejej	d¡¡Z
dZe ¡ Ze ¡ Ze ¡ ZdS )r   é   N)rp   rq   rr   r   rs   r   rt   ru   rv   r/  rx   r  r   ry   rz   r  r|   r}   r&   r&   r&   r'   r   ‡  s   c               @   sø   e Zd ZdZe ¡ ZG dd„ deƒZdd„ Z	dd„ Z
dd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedfdd„Zedddfdd„Zedfdd „Zedddfd!d"„Zed#d$„ ƒZd1d&d'„Zd2d(d)„Zd*d+„ Zd,d-„ Zd.d/„ Zd0S )3r   a:  Create |ASN.1| type.

    |ASN.1| objects are mutable and duck-type Python :class:`dict` objects.

    Keyword Args
    ------------
    componentType: :py:class:`~pyasn1.type.namedtype.NamedType`
        Object holding named ASN.1 types allowed within this collection

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    sizeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing collection size constraint

    Examples
    --------

    .. code-block:: python

        class Description(Sequence):  #  Set is similar
            '''
            ASN.1 specification:

            Description ::= SEQUENCE {
                surname    IA5String,
                first-name IA5String OPTIONAL,
                age        INTEGER DEFAULT 40
            }
            '''
            componentType = NamedTypes(
                NamedType('surname', IA5String()),
                OptionalNamedType('first-name', IA5String()),
                DefaultedNamedType('age', Integer(40))
            )

        descr = Description()
        descr['surname'] = 'Smith'
        descr['first-name'] = 'John'
    c               @   sP   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )zSequenceAndSetBase.DynamicNamesz9Fields names/positions mapping for component-less objectsc             C   s   i | _ i | _d S )N)Ú_keyToIdxMapÚ_idxToKeyMap)r#   r&   r&   r'   r"   Õ  s    z(SequenceAndSetBase.DynamicNames.__init__c             C   s
   t | jƒS )N)r”   r1  )r#   r&   r&   r'   r‰   Ù  s    z'SequenceAndSetBase.DynamicNames.__len__c             C   s   || j kp|| jkS )N)r1  r2  )r#   Úitemr&   r&   r'   râ   Ü  s    z,SequenceAndSetBase.DynamicNames.__contains__c                s   ‡ fdd„t tˆ jƒƒD ƒS )Nc             3   s   | ]}ˆ j | V  qd S )N)r2  )r–   rÿ   )r#   r&   r'   rÙ   à  s    z;SequenceAndSetBase.DynamicNames.__iter__.<locals>.<genexpr>)r›   r”   r2  )r#   r&   )r#   r'   r¡   ß  s    z(SequenceAndSetBase.DynamicNames.__iter__c             C   s*   y
| j | S  tk
r$   | j| S X d S )N)r1  rh   r2  )r#   r3  r&   r&   r'   r    â  s    
z+SequenceAndSetBase.DynamicNames.__getitem__c             C   s.   y
| j | S  tk
r(   t d¡‚Y nX d S )NzType position out of range)r2  rh   r   ri   )r#   rÿ   r&   r&   r'   ÚgetNameByPositioné  s    
z1SequenceAndSetBase.DynamicNames.getNameByPositionc             C   s4   y
| j | S  tk
r.   t d|f ¡‚Y nX d S )NzName %s not found)r1  rh   r   ri   )r#   r¸   r&   r&   r'   ÚgetPositionByNameð  s    
z1SequenceAndSetBase.DynamicNames.getPositionByNamec             C   s    || j d| < d| | j|< d S )Nzfield-%d)r1  r2  )r#   rÿ   r&   r&   r'   ÚaddField÷  s    z(SequenceAndSetBase.DynamicNames.addFieldN)rp   rq   rr   rs   r"   r‰   râ   r¡   r    r4  r5  r6  r&   r&   r&   r'   ÚDynamicNamesÓ  s   r7  c             K   s0   t jj| f|Ž t| jƒ| _| jp(|  ¡ | _d S )N)r   r  r"   r”   r  Ú_componentTypeLenr7  Ú_dynamicNames)r#   r%   r&   r&   r'   r"   ü  s    zSequenceAndSetBase.__init__c             C   st   t  |¡r>y
|  |¡S  tjk
r:   tt ¡ d ƒ‚Y qpX n2y
|  |¡S  tjk
rn   t	t ¡ d ƒ‚Y nX d S )Nrf   )
r   r¾   ÚgetComponentByNamer   ri   rh   rj   rk   r
  r�   )r#   rÿ   r&   r&   r'   r      s    


zSequenceAndSetBase.__getitem__c             C   s€   t  |¡rDy|  ||¡ W q| tjk
r@   tt ¡ d ƒ‚Y q|X n8y|  ||¡ W n& tjk
rz   t	t ¡ d ƒ‚Y nX d S )Nrf   )
r   r¾   ÚsetComponentByNamer   ri   rh   rj   rk   r  r�   )r#   rÿ   r$   r&   r&   r'   r    s    
zSequenceAndSetBase.__setitem__c             C   s   | j r|| jkS || jkS d S )N)r8  r  r9  )r#   r	  r&   r&   r'   râ   #  s    
zSequenceAndSetBase.__contains__c             C   s   t | jp| jƒS )N)rá   r  r9  )r#   r&   r&   r'   r¡   )  s    zSequenceAndSetBase.__iter__c             c   s,   x&t | jpt| jƒƒD ]}| | V  qW d S )N)r›   r8  r”   r9  )r#   rÿ   r&   r&   r'   r  .  s    zSequenceAndSetBase.valuesc             C   s   t | ƒS )N)rá   )r#   r&   r&   r'   Úkeys2  s    zSequenceAndSetBase.keysc             c   sT   xNt | jpt| jƒƒD ]6}| jr8| j| j| | fV  q| j| | | fV  qW d S )N)r›   r8  r”   r9  r  r¸   )r#   rÿ   r&   r&   r'   Úitems5  s    zSequenceAndSetBase.itemsc             O   s8   x|D ]\}}|| |< qW x|D ]}|| | |< q W d S )Nr&   )r#   Z	iterValueZmappingValueÚkrß   r&   r&   r'   Úupdate<  s    
zSequenceAndSetBase.updatec             C   s   g | _ |  ¡ | _d S )N)r  r7  r9  )r#   r&   r&   r'   r  B  s    zSequenceAndSetBase.clearc             C   sV   xPt | jƒD ]B\}}|tk	rt|tjƒr>| ||j|d�¡ q| || ¡ ¡ qW d S )N)r  )r  r  r   r@   r   r  r  r(   )r#   r  r  rÿ   r  r&   r&   r'   r  F  s    z(SequenceAndSetBase._cloneComponentValuesTc             C   sZ   | j r| j |¡}n6y| j |¡}W n$ tk
rH   t d|f ¡‚Y nX | j|||d�S )aG  Returns |ASN.1| type component by name.

        Equivalent to Python :class:`dict` subscription operation (e.g. `[]`).

        Parameters
        ----------
        name: :class:`str`
            |ASN.1| type component name

        Keyword Args
        ------------
        default: :class:`object`
            If set and requested component is a schema object, return the `default`
            object instead of the requested component.

        instantiate: :class:`bool`
            If `True` (default), inner component will be automatically instantiated.
            If 'False' either existing component or the `noValue` object will be
            returned.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            Instantiate |ASN.1| component type or return existing component value
        zName %s not found)r  r  )r8  r  r5  r9  rh   r   ri   r
  )r#   r¸   r  r  rÿ   r&   r&   r'   r:  P  s    z%SequenceAndSetBase.getComponentByNamec             C   s\   | j r| j |¡}n6y| j |¡}W n$ tk
rH   t d|f ¡‚Y nX |  |||||¡S )aV  Assign |ASN.1| type component by name.

        Equivalent to Python :class:`dict` item assignment operation (e.g. `[]`).

        Parameters
        ----------
        name: :class:`str`
            |ASN.1| type component name

        Keyword Args
        ------------
        value: :class:`object` or :py:class:`~pyasn1.type.base.PyAsn1Item` derivative
            A Python value to initialize |ASN.1| component with (if *componentType* is set)
            or ASN.1 value object to assign to |ASN.1| component.

        verifyConstraints: :class:`bool`
             If `False`, skip constraints validation

        matchTags: :class:`bool`
             If `False`, skip component tags matching

        matchConstraints: :class:`bool`
             If `False`, skip component constraints matching

        Returns
        -------
        self
        zName %s not found)r8  r  r5  r9  rh   r   ri   r  )r#   r¸   r$   r!  r"  r#  rÿ   r&   r&   r'   r;  u  s     z%SequenceAndSetBase.setComponentByNamec             C   sx   y| j | }W n tk
r&   t}Y nX |sB|tks:|js>|S |S |tkrT|  |¡ | j | }|tksl|jrp|S |S dS )aÊ  Returns |ASN.1| type component by index.

        Equivalent to Python sequence subscription operation (e.g. `[]`).

        Parameters
        ----------
        idx: :class:`int`
            Component index (zero-based). Must either refer to an existing
            component or (if *componentType* is set) new ASN.1 schema object gets
            instantiated.

        Keyword Args
        ------------
        default: :class:`object`
            If set and requested component is a schema object, return the `default`
            object instead of the requested component.

        instantiate: :class:`bool`
            If `True` (default), inner component will be automatically instantiated.
            If 'False' either existing component or the `noValue` object will be
            returned.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            a PyASN1 object

        Examples
        --------

        .. code-block:: python

            # can also be Set
            class MySequence(Sequence):
                componentType = NamedTypes(
                    NamedType('id', OctetString())
                )

            s = MySequence()

            # returns component #0 with `.isValue` property False
            s.getComponentByPosition(0)

            # returns None
            s.getComponentByPosition(0, default=None)

            s.clear()

            # returns noValue
            s.getComponentByPosition(0, instantiate=False)

            # sets component #0 to OctetString() ASN.1 schema
            # object and returns it
            s.getComponentByPosition(0, instantiate=True)

            # sets component #0 to ASN.1 value object
            s.setComponentByPosition(0, 'ABCD')

            # returns OctetString('ABCD') value object
            s.getComponentByPosition(0, instantiate=False)

            s.clear()

            # returns noValue
            s.getComponentByPosition(0, instantiate=False)
        N)r  r�   r   r  r  )r#   rÿ   r  r  r  r&   r&   r'   r
  ¢  s    C


z)SequenceAndSetBase.getComponentByPositionc             C   s  | j }| j}y| j| }W n: tk
rT   t}|rP||k rDt d¡‚tg| | _Y nX |tkr†|rr| |¡ ¡ }n|tkr„t d¡‚nèt	|t
jƒ�s|rÐ| |¡}	t	|	t
jƒr¼|	j|d�}nt d|jj ¡‚n4|tk	ròt	|t
jƒrò|j|d�}nt d|jj ¡‚nh|�s|�rn|�rn| |¡}	|	tk	�rn| j�r<|	j�p@|	j}
|
|||ƒ�sn|| j�snt d||f ¡‚|�rÈ|j�rÈy|  ||¡ W n: tjk
�rÆ   t ¡ \}}}|d|| jjf ƒ‚Y nX |�sÚ|| jk�ræ|| j|< n4t| jƒ|k�r| j |¡ | j |¡ n
t d¡‚| S )	aJ  Assign |ASN.1| type component by position.

        Equivalent to Python sequence item assignment operation (e.g. `[]`).

        Parameters
        ----------
        idx : :class:`int`
            Component index (zero-based). Must either refer to existing
            component (if *componentType* is set) or to N+1 component
            otherwise. In the latter case a new component of given ASN.1
            type gets instantiated and appended to |ASN.1| sequence.

        Keyword Args
        ------------
        value: :class:`object` or :py:class:`~pyasn1.type.base.PyAsn1Item` derivative
            A Python value to initialize |ASN.1| component with (if *componentType* is set)
            or ASN.1 value object to assign to |ASN.1| component.

        verifyConstraints : :class:`bool`
             If `False`, skip constraints validation

        matchTags: :class:`bool`
             If `False`, skip component tags matching

        matchConstraints: :class:`bool`
             If `False`, skip component constraints matching

        Returns
        -------
        self
        zcomponent index out of rangezComponent type not defined)r$   z%s can cast only scalar valuesz%s undefined component typez-Component value is tag-incompatible: %r vs %rz%s at %szComponent index out of range)r  r8  r  r�   r   r   ri   ÚgetTypeByPositionr(   r@   r   r  r!   r™   rp   r  r  r   ZopenTyper  rz   rj   rk   r9  r”   rÝ   r6  )r#   rÿ   r$   r!  r"  r#  r  ZcomponentTypeLenr$  ÚsubComponentTypeZsubtypeCheckerr%  r&  r'  r&   r&   r'   r  û  s\    #




z)SequenceAndSetBase.setComponentByPositionc             C   s~   | j }|rXxnt|jƒD ]<\}}|js|jr,q| js6dS | j| }|tksN|jsdS qW n"x | jD ]}|tksr|js`dS q`W dS )aW  Indicate that |ASN.1| object represents ASN.1 value.

        If *isValue* is `False` then this object represents just ASN.1 schema.

        If *isValue* is `True` then, in addition to its ASN.1 schema features,
        this object can also be used like a Python built-in object (e.g. `int`,
        `str`, `dict` etc.).

        Returns
        -------
        : :class:`bool`
            :class:`False` if object represents just ASN.1 schema.
            :class:`True` if object represents ASN.1 schema and can be used as a normal value.

        Note
        ----
        There is an important distinction between PyASN1 schema and value objects.
        The PyASN1 schema objects can only participate in ASN.1 schema-related
        operations (e.g. defining or testing the structure of the data). Most
        obvious uses of ASN.1 schema is to guide serialisation codecs whilst
        encoding/decoding serialised ASN.1 contents.

        The PyASN1 value objects can **additionally** participate in many operations
        involving regular Python objects (e.g. arithmetic, comprehension etc).
        FT)r  r  Z
namedTypesZisDefaultedZ
isOptionalr  r   r  )r#   r  rÿ   rA  r  r&   r&   r'   r  a	  s    

zSequenceAndSetBase.isValuer   c             C   s~   |d7 }| j jd }xdt| jƒD ]V\}}|tk	r |d| 7 }| jrT|| j |¡7 }n|| j |¡7 }d|| |¡f }q W |S )zšReturn an object representation string.

        Returns
        -------
        : :class:`str`
            Human-friendly object representation.
        rf   z:
r*  z%s=%s
)	r™   rp   r  r  r   r  r4  r9  rÛ   )r#   rÚ   r+  rÿ   r  r&   r&   r'   rÛ   ‘	  s    zSequenceAndSetBase.prettyPrintc             C   s¢   |d7 }d| j | jjf }xnt| j ¡ p,| jƒD ]V\}}|d| 7 }| jr`|d| j |¡ 7 }n|d| j |¡ 7 }d|| 	|¡f }q0W |d d|d   d S )Nrf   z%s -> %s {
r*  z"%s"z%s = %s
r,  r-  )
rx   r™   rp   r  r  r  r  r4  r9  r.  )r#   rÚ   r+  rÿ   r  r&   r&   r'   r.  §	  s    z"SequenceAndSetBase.prettyPrintTypec             C   s   | S )Nr&   )r#   r&   r&   r'   ÚsetDefaultComponents·	  s    z'SequenceAndSetBase.setDefaultComponentsc             C   s   | j r| jS d S )N)r8  r  )r#   r&   r&   r'   ÚgetComponentTypeº	  s    z#SequenceAndSetBase.getComponentTypec             C   s   | j r| j| jS d S )N)r8  r  r¸   )r#   rÿ   r&   r&   r'   r4  ¾	  s    z$SequenceAndSetBase.getNameByPositionN)r   )r   ) rp   rq   rr   rs   r	   Ú
NamedTypesr  Úobjectr7  r"   r    r  râ   r¡   r  r<  r=  r?  r  r  r   r:  r;  r
  r  r  r  rÛ   r.  rB  rC  r4  r&   r&   r&   r'   r   ¢  s<   +)
%*Yc0

c               @   sZ   e Zd ZejZe e ejej	d¡¡Z
e ¡ Ze ¡ Ze ¡ Ze ¡ Zdd„ Zdd„ ZdS )r   r¬   c             C   s   | j r| j  |¡S d S )N)r  ZgetTagMapNearPosition)r#   rÿ   r&   r&   r'   ÚgetComponentTagMapNearPositionß	  s    z'Sequence.getComponentTagMapNearPositionc             C   s   | j r| j  ||¡S |S d S )N)r  ZgetPositionNearType)r#   rx   rÿ   r&   r&   r'   ÚgetComponentPositionNearTypeã	  s    z%Sequence.getComponentPositionNearTypeN)rp   rq   rr   r   rs   r   rt   ru   rv   r/  rx   r   ry   rz   r  r	   rD  r  r|   r}   rF  rG  r&   r&   r&   r'   r   Ã	  s   c               @   s„   e Zd ZejZe e ejej	d¡¡Z
e ¡ Ze ¡ Ze ¡ Ze ¡ Zddd„Zeddfdd„Zeddddfdd	„Zed
d„ ƒZdS )r   r0  Fc             C   s   | S )Nr&   )r#   Ú	innerFlagr&   r&   r'   ÚgetComponent
  s    zSet.getComponentTc             C   s:   | j | j |¡||d�}|r2t|tƒr2|jdd�S |S dS )a  Returns |ASN.1| type component by ASN.1 tag.

        Parameters
        ----------
        tagSet : :py:class:`~pyasn1.type.tag.TagSet`
            Object representing ASN.1 tags to identify one of
            |ASN.1| object component

        Keyword Args
        ------------
        default: :class:`object`
            If set and requested component is a schema object, return the `default`
            object instead of the requested component.

        instantiate: :class:`bool`
            If `True` (default), inner component will be automatically instantiated.
            If 'False' either existing component or the `noValue` object will be
            returned.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            a pyasn1 object
        )r  r  T)rH  N)r
  r  ÚgetPositionByTyper@   r   rI  )r#   rx   r  r  rH  r  r&   r&   r'   ÚgetComponentByType
  s    

zSet.getComponentByTypec       	      C   sl   | j  |¡}|rV| j  |¡}|jr4|  |||||¡S |  |¡}|j||||||d�S n|  |||||¡S dS )a¾  Assign |ASN.1| type component by ASN.1 tag.

        Parameters
        ----------
        tagSet : :py:class:`~pyasn1.type.tag.TagSet`
            Object representing ASN.1 tags to identify one of
            |ASN.1| object component

        Keyword Args
        ------------
        value: :class:`object` or :py:class:`~pyasn1.type.base.PyAsn1Item` derivative
            A Python value to initialize |ASN.1| component with (if *componentType* is set)
            or ASN.1 value object to assign to |ASN.1| component.

        verifyConstraints : :class:`bool`
            If `False`, skip constraints validation

        matchTags: :class:`bool`
            If `False`, skip component tags matching

        matchConstraints: :class:`bool`
            If `False`, skip component constraints matching

        innerFlag: :class:`bool`
            If `True`, search for matching *tagSet* recursively.

        Returns
        -------
        self
        )rH  N)r  rJ  r@  rx   r  r
  ÚsetComponentByType)	r#   rx   r$   r!  r"  r#  rH  rÿ   r  r&   r&   r'   rL  ,
  s    #
zSet.setComponentByTypec             C   s   | j r| j jS d S )N)r  ÚtagMapUnique)r#   r&   r&   r'   r)  b
  s    zSet.componentTagMapN)F)rp   rq   rr   r   rs   r   rt   ru   rv   r/  rx   r	   rD  r  r   ry   rz   r  r|   r}   rI  r   rK  rL  r  r)  r&   r&   r&   r'   r   ê	  s    
$2c               @   s>  e Zd ZdZe ¡ Ze ¡ Z	e
 ¡ Ze
 e
 dd¡¡Ze ¡ ZdZdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Zejd dkrŠdd„ Zndd„ Zdd„ Zdd„ Zdd„ Zdd„ Z dd„ Z!d d!„ Z"d"d#„ Z#d$d%„ Z$e%d&fd'd(„Z&e%d&d&d&fd)d*„Z'e(d+d,„ ƒZ)e(d-d.„ ƒZ*d:d0d1„Z+d;d2d3„Z,e(d4d5„ ƒZ-d6d7„ Z.d8d9„ Z/dS )<r   aA  Create |ASN.1| type.

    |ASN.1| objects are mutable and duck-type Python :class:`dict` objects.

    Keyword Args
    ------------
    componentType: :py:class:`~pyasn1.type.namedtype.NamedType`
        Object holding named ASN.1 types allowed within this collection

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    sizeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing collection size constraint

    Examples
    --------

    .. code-block:: python

        class Afters(Choice):
            '''
            ASN.1 specification:

            Afters ::= CHOICE {
                cheese  [0] IA5String,
                dessert [1] IA5String
            }
            '''
            componentType = NamedTypes(
                NamedType('cheese', IA5String().subtype(
                    implicitTag=Tag(tagClassContext, tagFormatSimple, 0)
                ),
                NamedType('dessert', IA5String().subtype(
                    implicitTag=Tag(tagClassContext, tagFormatSimple, 1)
                )
            )

        afters = Afters()
        afters['cheese'] = 'Mascarpone'
    rf   Nc             C   s   | j r| j | j |kS tS )N)r  Ú_currentIdxÚNotImplemented)r#   r•   r&   r&   r'   rb   ®
  s    zChoice.__eq__c             C   s   | j r| j | j |kS tS )N)r  rN  rO  )r#   r•   r&   r&   r'   rc   ³
  s    zChoice.__ne__c             C   s   | j r| j | j |k S tS )N)r  rN  rO  )r#   r•   r&   r&   r'   r`   ¸
  s    zChoice.__lt__c             C   s   | j r| j | j |kS tS )N)r  rN  rO  )r#   r•   r&   r&   r'   ra   ½
  s    zChoice.__le__c             C   s   | j r| j | j |kS tS )N)r  rN  rO  )r#   r•   r&   r&   r'   rd   Â
  s    zChoice.__gt__c             C   s   | j r| j | j |kS tS )N)r  rN  rO  )r#   r•   r&   r&   r'   re   Ç
  s    zChoice.__ge__r   r   c             C   s   | j r
dpdS )NTF)r  )r#   r&   r&   r'   rý   Í
  s    zChoice.__nonzero__c             C   s   | j r
dpdS )NTF)r  )r#   r&   r&   r'   rþ   Ð
  s    zChoice.__bool__c             C   s   | j d k	rdpdS )Nrf   r   )rN  )r#   r&   r&   r'   r‰   Ó
  s    zChoice.__len__c             C   s"   | j d krdS || j| j   ¡ kS )NF)rN  r  ÚgetName)r#   r	  r&   r&   r'   râ   Ö
  s    
zChoice.__contains__c             c   s$   | j d krt‚| j| j   ¡ V  d S )N)rN  ÚStopIterationr  rP  )r#   r&   r&   r'   r¡   Û
  s    
zChoice.__iter__c             c   s   | j d k	r| j| j  V  d S )N)rN  r  )r#   r&   r&   r'   r  â
  s    
zChoice.valuesc             c   s    | j d k	r| j| j   ¡ V  d S )N)rN  r  rP  )r#   r&   r&   r'   r<  æ
  s    
zChoice.keysc             c   s*   | j d k	r&| j| j   ¡ | | j  fV  d S )N)rN  r  rP  )r#   r&   r&   r'   r=  ê
  s    
zChoice.itemsc             C   s   | j d krt d¡‚d S )NzComponent not chosen)rN  r   ri   )r#   r&   r&   r'   ÚverifySizeSpecî
  s    
zChoice.verifySizeSpecc             C   sr   y|   ¡ }W n tjk
r"   Y nLX t|tƒr6|j}n|j}t|tjƒr^| 	||j
|d�¡ n| 	|| 
¡ ¡ d S )N)r  )rI  r   ri   r@   r   ÚeffectiveTagSetrx   r   r  rL  r(   )r#   r  r  Ú	componentrx   r&   r&   r'   r  ò
  s    
zChoice._cloneComponentValuesTc             C   s6   t j}| jd ks| j|kr,t j| |||d�S | j| S )N)r  r  )r   rs   rN  r
  r  )r#   rÿ   r  r  rs   r&   r&   r'   r
    s
    
zChoice.getComponentByPositionc             C   s>   | j }t | |||||¡ || _ |dk	r:||kr:t| j|< | S )a®  Assign |ASN.1| type component by position.

        Equivalent to Python sequence item assignment operation (e.g. `[]`).

        Parameters
        ----------
        idx: :class:`int`
            Component index (zero-based). Must either refer to existing
            component or to N+1 component. In the latter case a new component
            type gets instantiated (if *componentType* is set, or given ASN.1
            object is taken otherwise) and appended to the |ASN.1| sequence.

        Keyword Args
        ------------
        value: :class:`object` or :py:class:`~pyasn1.type.base.PyAsn1Item` derivative
            A Python value to initialize |ASN.1| component with (if *componentType* is set)
            or ASN.1 value object to assign to |ASN.1| component. Once a new value is
            set to *idx* component, previous value is dropped.

        verifyConstraints : :class:`bool`
            If `False`, skip constraints validation

        matchTags: :class:`bool`
            If `False`, skip component tags matching

        matchConstraints: :class:`bool`
            If `False`, skip component constraints matching

        Returns
        -------
        self
        N)rN  r   r  r   r  )r#   rÿ   r$   r!  r"  r#  ZoldIdxr&   r&   r'   r    s    $
zChoice.setComponentByPositionc             C   s   | j r| j S |  ¡ }|jS dS )zwReturn a :class:`~pyasn1.type.tag.TagSet` object of the currently initialized component or self (if |ASN.1| is tagged).N)rx   rI  rS  )r#   rT  r&   r&   r'   rS  7  s    zChoice.effectiveTagSetc             C   s   | j rtj | ¡S | jjS dS )z†"Return a :class:`~pyasn1.type.tagmap.TagMap` object mapping
            ASN.1 tags to ASN.1 objects contained within callee.
        N)rx   r   r(  Úfgetr  rM  )r#   r&   r&   r'   r(  @  s    zChoice.tagMapFc             C   sB   | j dkrt d¡‚n(| j| j  }|r:t|tƒr:| |¡S |S dS )z³Return currently assigned component of the |ASN.1| object.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            a PyASN1 object
        NzComponent not chosen)rN  r   ri   r  r@   r   rI  )r#   rH  Úcr&   r&   r'   rI  J  s    

zChoice.getComponentc             C   sL   | j dkrt d¡‚n2|r:| j| j  }t|tƒr:| |¡S | j | j ¡S dS )z­Return the name of currently assigned component of the |ASN.1| object.

        Returns
        -------
        : :py:class:`str`
            |ASN.1| component name
        NzComponent not chosen)	rN  r   ri   r  r@   r   rP  r  r4  )r#   rH  rV  r&   r&   r'   rP  [  s    


zChoice.getNamec             C   s(   | j dkrdS | j| j  }|tk	o&|jS )aW  Indicate that |ASN.1| object represents ASN.1 value.

        If *isValue* is `False` then this object represents just ASN.1 schema.

        If *isValue* is `True` then, in addition to its ASN.1 schema features,
        this object can also be used like a Python built-in object (e.g. `int`,
        `str`, `dict` etc.).

        Returns
        -------
        : :class:`bool`
            :class:`False` if object represents just ASN.1 schema.
            :class:`True` if object represents ASN.1 schema and can be used as a normal value.

        Note
        ----
        There is an important distinction between PyASN1 schema and value objects.
        The PyASN1 schema objects can only participate in ASN.1 schema-related
        operations (e.g. defining or testing the structure of the data). Most
        obvious uses of ASN.1 schema is to guide serialisation codecs whilst
        encoding/decoding serialised ASN.1 contents.

        The PyASN1 value objects can **additionally** participate in many operations
        involving regular Python objects (e.g. arithmetic, comprehension etc).
        NF)rN  r  r   r  )r#   r  r&   r&   r'   r  l  s    
zChoice.isValuec             C   s   d | _ t | ¡ d S )N)rN  r   r  )r#   r&   r&   r'   r  Ž  s    zChoice.clearc             C   s   | j S )N)Z	minTagSet)r#   r&   r&   r'   ÚgetMinTagSet”  s    zChoice.getMinTagSet)F)F)0rp   rq   rr   rs   r   ÚTagSetrx   r	   rD  r  r   ry   rz   ZValueSizeConstraintr  r   r|   r}   rN  rb   rc   r`   ra   rd   re   rj   r~   rý   rþ   r‰   râ   r¡   r  r<  r=  rR  r  r   r
  r  r  rS  r(  rI  rP  r  r  rW  r&   r&   r&   r'   r   h
  sJ   ,
	(	


"c               @   s4   e Zd ZdZe ¡ Ze ¡ Z	e
 ¡ Zedd„ ƒZdS )r   a
  Create |ASN.1| schema or value object.

    |ASN.1| objects are immutable and duck-type Python 2 :class:`str` or Python 3
    :class:`bytes`. When used in Unicode context, |ASN.1| type assumes "|encoding|"
    serialisation.

    Keyword Args
    ------------
    value: :class:`str`, :class:`bytes` or |ASN.1| object
        string (Python 2) or bytes (Python 3), alternatively unicode object
        (Python 2) or string (Python 3) representing character string to be
        serialised into octets (note `encoding` parameter) or |ASN.1| object.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s)

    encoding: :py:class:`str`
        Unicode codec ID to encode/decode :class:`unicode` (Python 2) or
        :class:`str` (Python 3) the payload when |ASN.1| object is used
        in text string context.

    binValue: :py:class:`str`
        Binary string initializer to use instead of the *value*.
        Example: '10110011'.

    hexValue: :py:class:`str`
        Hexadecimal string initializer to use instead of the *value*.
        Example: 'DEADBEEF'.

    Raises
    ------
    :py:class:`~pyasn1.error.PyAsn1Error`
        On constraint violation or bad initializer.

    Examples
    --------
    .. code-block:: python

        class Error(Sequence):
            '''
            ASN.1 specification:

            Error ::= SEQUENCE {
                code      INTEGER,
                parameter ANY DEFINED BY code  -- Either INTEGER or REAL
            }
            '''
            componentType=NamedTypes(
                NamedType('code', Integer()),
                NamedType('parameter', Any(),
                          openType=OpenType('code', {1: Integer(),
                                                     2: Real()}))
            )

        error = Error()
        error['code'] = 1
        error['parameter'] = Integer(1234)
    c             C   sB   y| j S  tk
r<   t | j| itjjtji| ¡| _ | j S X dS )z†"Return a :class:`~pyasn1.type.tagmap.TagMap` object mapping
            ASN.1 tags to ASN.1 objects contained within callee.
        N)Z_tagMapÚAttributeErrorr   ZTagMaprx   r   ZendOfOctets)r#   r&   r&   r'   r(  ã  s    z
Any.tagMapN)rp   rq   rr   rs   r   rX  rx   r   ry   rz   r   r|   r}   r  r(  r&   r&   r&   r'   r   ˜  s
   =)0rX   rj   Zpyasn1r   Zpyasn1.codec.berr   Zpyasn1.compatr   r   r   Zpyasn1.typer   r   r	   r
   r   r   r   r   Ú__all__r!   r   r   r~   rK   ZSizedIntegerBaserI   r„   r   rÊ   Ú	NameErrorr   r   rÄ   rA   ró   r   r   r   r  r   r   r   r   r   r   r   r   r&   r&   r&   r'   Ú<module>   s~   

 u;  b  30

   C  M    %'~  2