
    ci                       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 e	j                  Z e       Zg dZ G d de	j$                        Z G d de      Z G d de      Z G d de	j$                        Z G d de	j$                        Z G d de      Z G d de	j$                        Z G d de	j$                        Z G d de	j$                        Z G d de      Z G d  d!e	j<                        Z G d" d#e      Z  G d$ d%e      Z! G d& d'e	j<                        Z" G d( d)e"      Z# G d* d+e"      Z$ G d, d-e$      Z% G d. d/e      Z&y)0    N)error)eoo)integer)base)
constraint)	namedtype)namedval)tag)tagmap)IntegerBoolean	BitStringOctetStringNullObjectIdentifierReal
EnumeratedSequenceOfAndSetOfBase
SequenceOfSetOfSequenceAndSetBaseSequenceSetChoiceAnyNoValuenoValuec                   :   e Zd ZdZ ej
                   ej                  ej                  ej                  d            Z	 e
j                         Z ej                         Zej"                  j%                         ZefdZd Zd Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d1dZ&d Z'd Z(d Z)d Z*d Z+d Z,d Z-ej"                  j\                  Z.d Z/d Z0d Z1d  Z2d! Z3d" Z4d# Z5d2d$Z6d% Z7d& Z8d' Z9d( Z:d) Z;d* Z<d+ Z=d, Z>d- Z?d. Z@d/ ZAd0 ZBy)3r   a  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    objects are immutable and duck-type Python :class:`int` objects.

    Keyword Args
    ------------
    value: :class:`int`, :class:`str` or |ASN.1| object
        Python :class:`int` or :class:`str` literal or |ASN.1| class
        instance. If `value` is not given, schema object will be created.

    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). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

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

    Raises
    ------
    ~pyasn1.error.ValueConstraintError, ~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                 l    d|vr| j                   |d<   t        j                  j                  | |fi | y )NnamedValues)r!   r   SimpleAsn1Type__init__selfvaluekwargss      7/tmp/pip-target-z3e9_cxr/lib/python/pyasn1/type/univ.pyr#   zInteger.__init__e   s5    &$($4$4F=!$$T5;F;    c                 >    | j                  | j                  |z        S Nclone_valuer%   r&   s     r(   __and__zInteger.__and__k       zz$++-..r)   c                 >    | j                  || j                  z        S r+   r,   r/   s     r(   __rand__zInteger.__rand__n       zz%$++-..r)   c                 >    | j                  | j                  |z        S r+   r,   r/   s     r(   __or__zInteger.__or__q   r1   r)   c                 >    | j                  || j                  z        S r+   r,   r/   s     r(   __ror__zInteger.__ror__t   r4   r)   c                 >    | j                  | j                  |z        S r+   r,   r/   s     r(   __xor__zInteger.__xor__w   r1   r)   c                 >    | j                  || j                  z        S r+   r,   r/   s     r(   __rxor__zInteger.__rxor__z   r4   r)   c                 >    | j                  | j                  |z        S r+   r,   r/   s     r(   
__lshift__zInteger.__lshift__}       zz$++.//r)   c                 >    | j                  | j                  |z	        S r+   r,   r/   s     r(   
__rshift__zInteger.__rshift__   r?   r)   c                 >    | j                  | j                  |z         S r+   r,   r/   s     r(   __add__zInteger.__add__   r1   r)   c                 >    | j                  || j                  z         S r+   r,   r/   s     r(   __radd__zInteger.__radd__   r4   r)   c                 >    | j                  | j                  |z
        S r+   r,   r/   s     r(   __sub__zInteger.__sub__   r1   r)   c                 >    | j                  || j                  z
        S r+   r,   r/   s     r(   __rsub__zInteger.__rsub__   r4   r)   c                 >    | j                  | j                  |z        S r+   r,   r/   s     r(   __mul__zInteger.__mul__   r1   r)   c                 >    | j                  || j                  z        S r+   r,   r/   s     r(   __rmul__zInteger.__rmul__   r4   r)   c                 >    | j                  | j                  |z        S r+   r,   r/   s     r(   __mod__zInteger.__mod__   r1   r)   c                 >    | j                  || j                  z        S r+   r,   r/   s     r(   __rmod__zInteger.__rmod__   r4   r)   Nc                 N    | j                  t        | j                  ||            S r+   r-   powr.   r%   r&   modulos      r(   __pow__zInteger.__pow__   s    zz#dkk5&9::r)   c                 L    | j                  t        || j                              S r+   rS   r/   s     r(   __rpow__zInteger.__rpow__   s    zz#eT[[122r)   c                 >    | j                  | j                  |z        S r+   r,   r/   s     r(   __floordiv__zInteger.__floordiv__   r?   r)   c                 >    | j                  || j                  z        S r+   r,   r/   s     r(   __rfloordiv__zInteger.__rfloordiv__   s    zz%4;;.//r)   c                 2    t        | j                  |z        S r+   r   r.   r/   s     r(   __truediv__zInteger.__truediv__   s    DKK%'((r)   c                 2    t        || j                  z        S r+   r_   r/   s     r(   __rtruediv__zInteger.__rtruediv__   s    EDKK'((r)   c                 L    | j                  t        | j                  |            S r+   r-   divmodr.   r/   s     r(   
__divmod__zInteger.__divmod__   s    zz&e455r)   c                 L    | j                  t        || j                              S r+   rd   r/   s     r(   __rdivmod__zInteger.__rdivmod__   s    zz&455r)   c                 ,    t        | j                        S r+   intr.   r%   s    r(   __int__zInteger.__int__       4;;r)   c                 ,    t        | j                        S r+   floatr.   rl   s    r(   	__float__zInteger.__float__       T[[!!r)   c                 J    | j                  t        | j                              S r+   )r-   absr.   rl   s    r(   __abs__zInteger.__abs__   s    zz#dkk*++r)   c                 ,    t        | j                        S r+   rj   rl   s    r(   	__index__zInteger.__index__   rn   r)   c                 :    | j                  | j                        S r+   r,   rl   s    r(   __pos__zInteger.__pos__       zz4;;,''r)   c                 :    | j                  | j                         S r+   r,   rl   s    r(   __neg__zInteger.__neg__   r{   r)   c                 :    | j                  | j                         S r+   r,   rl   s    r(   
__invert__zInteger.__invert__   r{   r)   c                 X    t        | j                  |      }|r| j                  |      S |S r+   )roundr.   r-   r%   nrs      r(   	__round__zInteger.__round__   s(    $++q!::a= Hr)   c                 @    t        j                  | j                        S r+   )mathfloorr.   rl   s    r(   	__floor__zInteger.__floor__   s    zz$++&&r)   c                 @    t        j                  | j                        S r+   )r   ceilr.   rl   s    r(   __ceil__zInteger.__ceil__   s    yy%%r)   c                 ^    | j                  t        j                  | j                              S r+   )r-   r   truncr.   rl   s    r(   	__trunc__zInteger.__trunc__   s    zz$**T[[122r)   c                      | j                   |k  S r+   r.   r/   s     r(   __lt__zInteger.__lt__       {{U""r)   c                      | j                   |k  S r+   r   r/   s     r(   __le__zInteger.__le__       {{e##r)   c                      | j                   |k(  S r+   r   r/   s     r(   __eq__zInteger.__eq__   r   r)   c                      | j                   |k7  S r+   r   r/   s     r(   __ne__zInteger.__ne__   r   r)   c                      | j                   |kD  S r+   r   r/   s     r(   __gt__zInteger.__gt__   r   r)   c                      | j                   |k\  S r+   r   r/   s     r(   __ge__zInteger.__ge__   r   r)   c                     	 t        |      S # t        $ r? 	 | j                  |   cY S # t        $ r }t	        j
                  d|d|      d }~ww xY ww xY w)NzCan't coerce z into integer: )rk   
ValueErrorr!   KeyErrorr   PyAsn1Errorr%   r&   excs      r(   prettyInzInteger.prettyIn   sa    
	u: 	''.. '';@#F 		s(   
 	A(A	AAAAc                 h    	 t        | j                  |         S # t        $ r t        |      cY S w xY wr+   )strr!   r   r/   s     r(   	prettyOutzInteger.prettyOut   s6    	t''.// 	u:	s    11c                     | j                   S r+   )r!   rl   s    r(   getNamedValueszInteger.getNamedValues  s    r)   r+   r   )C__name__
__module____qualname____doc__r
   
initTagSetTagtagClassUniversaltagFormatSimpletagSetr   ConstraintsIntersectionsubtypeSpecr	   NamedValuesr!   r   r"   	getTypeIdtypeIdr   r#   r0   r3   r6   r8   r:   r<   r>   rA   rC   rE   rG   rI   rK   rM   rO   rQ   rW   rY   r[   r]   r`   rb   rf   rh   __hash__rm   rr   rv   rx   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r)   r(   r   r       si   0h S^^%%s':':DAF 5*446K '(&&(K   **,F$ <//////00////////;300))66 ""++H ", ((('&3#$$$#$ r)   r   c                      e Zd ZdZ ej
                   ej                  ej                  ej                  d            Z	e
j                   ej                  dd      z   Z ej                  dd      Ze
j#                         Zy)r   ad  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    objects are immutable and duck-type Python :class:`int` objects.

    Keyword Args
    ------------
    value: :class:`int`, :class:`str` or |ASN.1| object
        Python :class:`int` or :class:`str` literal or |ASN.1| class
        instance. If `value` is not given, schema object will be created.

    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).Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

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

    Raises
    ------
    ~pyasn1.error.ValueConstraintError, ~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)
       r   )Falser   )Truer   N)r   r   r   r   r
   r   r   r   r   r   r   r   r   SingleValueConstraintr	   r   r!   r   r   r   r)   r(   r   r     s    *\ S^^%%s':':DAF %%(H
(H(HA(NNK '(&&|[AK  Fr)   r   c                        e Zd ZdxZZd Zd Zy)SizedIntegerNc                 X    || _         t        || j                         z
  d      | _        | S Nr   )	bitLengthmax
bit_lengthleadingZeroBits)r%   r   s     r(   setBitLengthzSizedInteger.setBitLengthI  s)    ""9t/@#@!Dr)   c                 p    | j                   | j                  | j                                | j                   S r+   )r   r   r   rl   s    r(   __len__zSizedInteger.__len__N  s+    >>!doo/0~~r)   )r   r   r   r   r   r   r   r   r)   r(   r   r   F  s    "&&I
r)   r   c                      e Zd ZdZ ej
                   ej                  ej                  ej                  d            Z	 e
j                         Z ej                         Zej"                  j%                         ZexZZefdZd Zd Zd Zd Zd Zd	 Zd
 Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.e/d d       Z0e/d d       Z1e/d!d       Z2d Z3y)"r   a  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    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 :class:`int` or :class:`str` literal representing binary
        or hexadecimal number or sequence of integer bits or |ASN.1| object.
        If `value` is not given, schema object will be created.

    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). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

    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
    ------
    ~pyasn1.error.ValueConstraintError, ~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)
       c                    |t         u rH|rF	 | j                  |j                  d      d      }	 | j	                  |j                  d      d      }|t         u r_| j
                  t         ur| j                  | j
                  d      }n/| j                  t         ur| j	                  | j                  d      }d|vr| j                  |d<   t        j                  j                  | |fi | y # t        $ r Y w xY w# t        $ r Y w xY w)NbinValueTinternalFormathexValuer!   )r   fromBinaryStringpopr   fromHexStringdefaultBinValuedefaultHexValuer!   r   r"   r#   r$   s      r(   r#   zBitString.__init__  s   G 11&**Z2HY]1^E
 ..vzz*/EVZ.[E
 G##72--d.B.BSW-X%%W4**4+?+?PT*U&$($4$4F=!$$T5;F;'      s"   "C- "C< -	C98C9<	DDc                 "    | j                         S r+   )asBinaryrl   s    r(   __str__zBitString.__str__  s    }}r)   c                     | j                  |      }| |u xs2 | j                  |k(  xr! t        | j                        t        |      k(  S r+   r   r.   lenr%   others     r(   r   zBitString.__eq__  s@    e$u}Wu 4 WT[[9ISQVZ9WWr)   c                     | j                  |      }| j                  |k7  xs! t        | j                        t        |      k7  S r+   r   r   s     r(   r   zBitString.__ne__  s6    e${{e#Es4;;'73u:'EEr)   c                     | j                  |      }t        | j                        t        |      k  xs2 t        | j                        t        |      k(  xr | j                  |k  S r+   r   r   r.   r   s     r(   r   zBitString.__lt__  Q    e$4;;#e*,fDKK0@CJ0N0fSWS^S^afSffr)   c                     | j                  |      }t        | j                        t        |      k  xs2 t        | j                        t        |      k(  xr | j                  |k  S r+   r   r   s     r(   r   zBitString.__le__  Q    e$4;;3u:-hT[[1ASZ1O1hTXT_T_chThhr)   c                     | j                  |      }t        | j                        t        |      kD  xs2 t        | j                        t        |      k(  xr | j                  |kD  S r+   r   r   s     r(   r   zBitString.__gt__  r   r)   c                     | j                  |      }t        | j                        t        |      k\  xs2 t        | j                        t        |      k(  xr | j                  |k\  S r+   r   r   s     r(   r   zBitString.__ge__  r   r)   c                 ,    t        | j                        S r+   r   r.   rl   s    r(   r   zBitString.__len__  rn   r)   c           	      4   |j                   t        u r@| j                  t        |j	                  t        |              D cg c]  }| |   	 c}      S t        | j                        dz
  }||kD  s|dk  rt        d      | j                  ||z
  z	  dz  S c c}w )Nr   r   zbit index out of range)	__class__slicer-   rangeindicesr   r.   
IndexError)r%   ixlengths       r(   __getitem__zBitString.__getitem__  s    ;;%::qyyT7K0LM1tAwMNN%)F6zQU !9::KKFQJ/144 Ns    Bc              #   t   K   t        | j                        }|r|dz  }| j                  |z	  dz   |ry y wNr   r   )r%   r   s     r(   __iter__zBitString.__iter__  s9     T[[!aKF;;&(A-- s   388c                 *    t        t        |             S r+   )reversedtuplerl   s    r(   __reversed__zBitString.__reversed__  s    d$$r)   c                     | j                  |      }| j                  t        | j                  t	        |      z  |z        j                  t	        | j                        t	        |      z               S r+   )r   r-   r   r.   r   r   r/   s     r(   rC   zBitString.__add__  sZ    e$zz,t{{c%j'@5'HIVVWZ[_[f[fWgjmnsjtWtuvvr)   c                     | j                  |      }| j                  t        |t        | j                        z  | j                  z        j                  t        | j                        t        |      z               S r+   )r   r-   r   r   r.   r   r/   s     r(   rE   zBitString.__radd__  s_    e$zz,uDKK0@'@4;;'NO\\]`aealal]mpstypz]z{||r)   c                     | j                   }|dkD  r2|t        | j                         z  }|| j                   z  }|dz  }|dkD  r2| j                  |      S r   )r.   r   r-   )r%   r&   	bitStrings      r(   rK   zBitString.__mul__  sV    KK	ai#dkk**I$IQJE ai zz)$$r)   c                     | |z  S r+   r   r/   s     r(   rM   zBitString.__rmul__	      e|r)   c                     | j                  t        | j                  |z        j                  t	        | j                        |z               S r+   )r-   r   r.   r   r   r%   counts     r(   r>   zBitString.__lshift__  s9    zz,t{{e';<II#dkkJZ]bJbcddr)   c           
          | j                  t        | j                  |z	        j                  t	        dt        | j                        |z
                    S r   )r-   r   r.   r   r   r   r  s     r(   rA   zBitString.__rshift__  sD    zz,t{{e';<II#aQTUYU`U`QadiQiJjkllr)   c                 ,    t        | j                        S r+   rj   rl   s    r(   rm   zBitString.__int__  rn   r)   c                 ,    t        | j                        S r+   rp   rl   s    r(   rr   zBitString.__float__  rs   r)   c                 4    t        | j                               S )zGet |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   asOctetsrl   s    r(   	asNumberszBitString.asNumbers  s     T]]_%%r)   c                 V    t        j                  | j                  t        |             S )zGet |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   rl   s    r(   r  zBitString.asOctets   s     CI>>r)   c                     | j                   S )z5Get |ASN.1| value as a single integer value.
        r   rl   s    r(   	asIntegerzBitString.asInteger(  s     {{r)   c                     t        | j                        dd }dt        | j                        t        |      z
  z  |z   S )z4Get |ASN.1| value as a text string of bits.
        r   N0)binr.   r   )r%   	binStrings     r(   r   zBitString.asBinary-  s;     $QR(	c$++&Y789DDr)   Nc                 f   	 t        |d      j                  t        |      dz        }|Gt        t        |      t        |      z  |z        j                  t        |      t        |      z         }|s | |      }|S # t        $ r)}t	        j
                  | j                  d|      d}~ww xY w)Create a |ASN.1| object initialized from the hex string.

        Parameters
        ----------
        value: :class:`str`
            Text string like 'DEADBEEF'
              z.fromHexString() error: Nr   r   r   r   r   r   r   clsr&   r   prependr   s        r(   r   zBitString.fromHexString3  s    	Z +88UaHE
  g&#e*4=l3w<#e*45  JE  	Z##cllTW$XYY	Zs   'A> >	B0$B++B0c                 h   	 t        |xs dd      j                  t        |            }|Gt        t        |      t        |      z  |z        j                  t        |      t        |      z         }|s | |      }|S # t        $ r)}t	        j
                  | j                  d|      d}~ww xY w)Create a |ASN.1| object initialized from a string of '0' and '1'.

        Parameters
        ----------
        value: :class:`str`
            Text string like '1010111'
        r  r   z.fromBinaryString() error: Nr  r  s        r(   r   zBitString.fromBinaryStringL  s    	] #q1>>s5zJE
  g&#e*4=l3w<#e*45  JE  	]##WZ$[\\	]s   (A? ?	B1$B,,B1c                 >   t        t        j                  t        |      d      |z	        j	                  t        |      dz  |z
        }|Gt        t        |      t        |      z  |z        j	                  t        |      t        |      z         }|s | |      }|S )zCreate a |ASN.1| object initialized from a string.

        Parameters
        ----------
        value: :class:`bytes`
            Text string like b'\\x01\\xff'
        big   )r   rk   
from_bytesbytesr   r   )r  r&   r   r  paddings        r(   fromOctetStringzBitString.fromOctetStringe  s     S^^E%L%@GKLYYZ]^cZdghZhkrZrs g&#e*4=l3w<#e*45  JEr)   c           	         t        |t              r|S t        |t              rz|st        d      j                  d      S |d   dk(  rT|dd  dk(  r| j	                  |dd d      S |dd  dk(  r| j                  |dd d      S t        j                  d	|      | j                  r|j                         s|j                  d
      D cg c]  }|j                          }}	 |D cg c]  }| j                  |    }}t        |      }d}|D ]  }|d||z
  z  z  } t        |      j                  |dz         S |j                  d      r| j                  |dd  d      S |j                  d      r| j	                  |dd  d      S | j	                  |d      S t        |t        t         f      r8| j	                  dj#                  |D 	cg c]  }	|	xr dxs d c}	      d      S t        |t$              r#t        |      j                  t'        |            S t        |t(              rt        |      S t        j                  d|d      c c}w c c}w # t        $ r t        j                  d|      w xY wc c}	w )Nr   'z'Br   Tr   z'HzBad BIT STRING value notation ,zunknown bit name(s) in 0xr   0b 1r  z Bad BitString initializer type ')
isinstancer   r   r   r   r   r   r   r!   isdigitsplitstripr   r   
startswithr   listjoinr   r   rk   )
r%   r&   r   namesnamebitPositionsrightmostPositionnumberbitPositionbs
             r(   r   zBitString.prettyInz  s   e\*Ls##A33A66qT!:&00qT0RR23Z5(--eAbk$-OO++>CE  !!%--/,1KK,<=q==TGL#MtD$4$4T$:#ML#M
 %($5!#/ EKa$5$CDDFE $F+889JQ9NOO!!$'))%)D)II!!$',,U12Yt,LL ,,U4,HHt}-((E1Rq!)2Bs2B1R)Sdh(iiy)&33CJ??s#&& ##;@B I > $N T++5,RSST* 2Ss*   I%I )I?I JI "I?)FN)FNr   )4r   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   r   r   r   r   r   r   r   r   r   rC   rE   rK   rM   r>   rA   rm   rr   r	  r  r  r   classmethodr   r   r"  r   r   r)   r(   r   r   U  sC   >D S^^%%s':':DAF 5*446K '(&&(K   **,F(//Oo$ <6XFgigi 5.%
w}%em "&?
E  0  0  (8r)   r   c                   z   e Zd ZdZ ej
                   ej                  ej                  ej                  d            Z	 e
j                         Zej                  j                         ZexZZdZefdZd Zd Zd Zd Zd	 Zd
 ZddZed        Zed        Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*y)r   a  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    objects are immutable and duck-type :class:`bytes`.
    When used in Unicode context, |ASN.1| type
    assumes "|encoding|" serialisation.

    Keyword Args
    ------------
    value: :class:`unicode`, :class:`str`, :class:`bytes` or |ASN.1| object
        :class:`bytes`, alternatively :class:`str`
        representing character string to be serialised into octets
        (note `encoding` parameter) or |ASN.1| object.
        If `value` is not given, schema object will be created.

    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). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

    encoding: :py:class:`str`
        Unicode codec ID to encode/decode
        :class:`str` 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
    ------
    ~pyasn1.error.ValueConstraintError, ~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                    |rJ|t         u rB	 | j                  |j                  d            }	 | j	                  |j                  d            }|t         u r[| j
                  t         ur| j                  | j
                        }n-| j                  t         ur| j	                  | j                        }d|vr| j                  |d<   t        j                  j                  | |fi | y # t        $ r Y w xY w# t        $ r Y w xY w)Nr   r   encoding)r   r   r   r   r   r   r   r<  r   r"   r#   r$   s      r(   r#   zOctetString.__init__  s     11&**Z2HIE
 ..vzz*/EFE
 G##72--d.B.BC%%W4**4+?+?@V#!%F:$$T5;F;'      s"    C%  C4 %	C10C14	D ?D c                    t        |t              r|S t        |t              r	 |j                  | j                        S t        |t              r|j                         S t        |t        j                        r| j                  t        |            S t        |t        t        f      r| j                  t        |            S t        |      S # t
        $ r,}t        j                  d|d| j                  d|      d }~ww xY w)NzCan't encode string '' with 'z' codec)r+  r   r   encoder<  UnicodeEncodeErrorr   PyAsn1UnicodeEncodeErrorr   r  r   r"   r   r   r0  r   s      r(   r   zOctetString.prettyIn  s    eU#Ls#||DMM22 {+>>##t223==U,,t}-==u.. < & 44$dmm569 s   C 	D'C>>Dc           
          	 | j                   j                  | j                        S # t        $ rM}t	        j
                  d| j                   d| j                  d| j                  j                  d|      d }~ww xY w)NzCan't decode string 'r>  z' codec at 'r$  )r.   decoder<  UnicodeDecodeErrorr   PyAsn1UnicodeDecodeErrorr   r   )r%   r   s     r(   r   zOctetString.__str__5  se    	;;%%dmm44! 	00++t}} NN33569 	s   $' 	A=AA88A=c                 ,    t        | j                        S r+   r   r.   rl   s    r(   	__bytes__zOctetString.__bytes__@  rs   r)   c                 ,    t        | j                        S r+   rG  rl   s    r(   r  zOctetString.asOctetsC  rs   r)   c                 ,    t        | j                        S r+   )r   r.   rl   s    r(   r	  zOctetString.asNumbersF  rs   r)   c                     |S r+   r   r/   s     r(   r   zOctetString.prettyOut[  s    r)   c                     | j                  | j                        }|| j                  ur|S | j                         }|D ])  }|dk  s|dkD  sddj                  d |D              z   c S  t        j                  |       S )N    ~   r'  r)  c              3   &   K   | ]	  }d |z    yw)z%.2xNr   ).0r   s     r(   	<genexpr>z*OctetString.prettyPrint.<locals>.<genexpr>j  s     &Cavz&Cs   )r   r.   r	  r1  r   r   )r%   scoper&   numbersr   s        r(   prettyPrintzOctetString.prettyPrint^  sz    t{{+#L.." 	-A2vSbgg&C7&CDDD	- &&t,,r)   c                     d}d}g }| D ]O  }|r|dz  }nd}|j                  |       d}|dv rt        |      }nt        j                  d|      |||z  z  }Q |j                  |       t	        |      S )r  r  r   r      )r  r*  z$Non-binary OCTET STRING initializer )appendrk   r   r   r   )r&   bitNobyter   vs        r(   r   zOctetString.fromBinaryStringo  s      	A
JF''@AC  AJD	 	
Qxr)   c                     g }g }| D ]'  }|r!|j                  t        ||z   d             d}&|}) |r|j                  t        |dz   d             t        |      S )r  r  Nr  )rW  rk   r   )r&   r   prZ  s       r(   r   zOctetString.fromHexString  se      	AQUB(	 HHSS"%&Qxr)   c                 ,    t        | j                        S r+   r   rl   s    r(   r   zOctetString.__len__  rn   r)   c                     |j                   t        u r| j                  | j                  |         S | j                  |   S r+   r   r   r-   r.   r%   r   s     r(   r   zOctetString.__getitem__  3    ;;%::dkk!n--;;q>!r)   c                 ,    t        | j                        S r+   iterr.   rl   s    r(   r   zOctetString.__iter__      DKK  r)   c                     || j                   v S r+   r   r/   s     r(   __contains__zOctetString.__contains__      ##r)   c                 \    | j                  | j                  | j                  |      z         S r+   )r-   r.   r   r/   s     r(   rC   zOctetString.__add__  s#    zz$++e(<<==r)   c                 \    | j                  | j                  |      | j                  z         S r+   )r-   r   r.   r/   s     r(   rE   zOctetString.__radd__  s#    zz$--.<==r)   c                 >    | j                  | j                  |z        S r+   r,   r/   s     r(   rK   zOctetString.__mul__  r1   r)   c                     | |z  S r+   r   r/   s     r(   rM   zOctetString.__rmul__  r   r)   c                 ,    t        | j                        S r+   rj   rl   s    r(   rm   zOctetString.__int__  rn   r)   c                 ,    t        | j                        S r+   rp   rl   s    r(   rr   zOctetString.__float__  rs   r)   c                 ,    t        | j                        S r+   )r   r.   rl   s    r(   r   zOctetString.__reversed__  s    $$r)   Nr   )+r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r"   r   r   r   r   r   r<  r#   r   r   rH  r  r	  r   rT  staticmethodr   r   r   r   r   rg  rC   rE   rK   rM   rm   rr   r   r   r)   r(   r   r     s    8x S^^%%s':':DAF 5*446K   **,F(//OoH$ <6 2	"""*-"  <  . "!$>>/ "%r)   r   c                       e Zd ZdZ ej
                   ej                  ej                  ej                  d            Z	e
j                   ej                  d      z   Ze
j                         Zd Zy)r   ai  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    objects are immutable and duck-type Python :class:`str` objects
    (always empty).

    Keyword Args
    ------------
    value: :class:`str` or |ASN.1| object
        Python empty :class:`str` literal or any object that evaluates to :obj:`False`
        If `value` is not given, schema object will be created.

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

    Raises
    ------
    ~pyasn1.error.ValueConstraintError, ~pyasn1.error.PyAsn1Error
        On constraint violation or bad initializer.

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

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

            Ack ::= NULL
            '''
        ack = Ack('')
       r)   c                     |r|S y)Nr)   r   r/   s     r(   r   zNull.prettyIn  s    Lr)   N)r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r)   r(   r   r     sm    H S^^%%s':':DAF )),LJ,L,LS,QQK ""$Fr)   r   c                      e Zd ZdZ ej
                   ej                  ej                  ej                  d            Z	 e
j                         Zej                  j                         Zd Zd Zd Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zy)r   a5  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    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 :class:`str` literal or |ASN.1| object.
        If `value` is not given, schema object will be created.

    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). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

    Raises
    ------
    ~pyasn1.error.ValueConstraintError, ~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                 >    | j                  | j                  |z         S r+   r,   r   s     r(   rC   zObjectIdentifier.__add__8  r1   r)   c                 >    | j                  || j                  z         S r+   r,   r   s     r(   rE   zObjectIdentifier.__radd__;  r4   r)   c                     | j                   S r+   r   rl   s    r(   asTuplezObjectIdentifier.asTuple>      {{r)   c                 ,    t        | j                        S r+   r   rl   s    r(   r   zObjectIdentifier.__len__C  rn   r)   c                     |j                   t        u r| j                  | j                  |         S | j                  |   S r+   r_  r`  s     r(   r   zObjectIdentifier.__getitem__F  ra  r)   c                 ,    t        | j                        S r+   rc  rl   s    r(   r   zObjectIdentifier.__iter__L  re  r)   c                     || j                   v S r+   r   r/   s     r(   rg  zObjectIdentifier.__contains__O  rh  r)   c                 8    | j                   j                  |      S r+   r.   indexr%   suboids     r(   r  zObjectIdentifier.indexR      {{  ((r)   c                 b    t        |       }|t        |      k  r| j                  d| |d| k(  ryy)ar  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`
            :obj:`True` if this |ASN.1| object is a parent (e.g. prefix) of the other |ASN.1| object
            or :obj:`False` otherwise.
        NTFr   r%   r   ls      r(   
isPrefixOfzObjectIdentifier.isPrefixOfU  s6     IE
?{{2A%)+r)   c           	      f   t        |t              rt        |      S t        |t              rd|v rGt	        j
                  d|d| j                  j                  dt        j                         d         	 t        |j                  d      D cg c]  }|st        |       c}      S 	 t        |D cg c]  }|dk\  s	t        |       c}      }t        |      t        |      k(  r|S t	        j
                  d|d| j                  j                        c c}w # t        $ r7}t	        j
                  d|d| j                  j                  d|      d }~ww xY wc c}w # t        t        f$ r7}t	        j
                  d|d| j                  j                  d|      d }~ww xY w)N-zMalformed Object ID  at : r   .r   )r+  r   r   r   r   r   r   r   sysexc_infor-  rk   r   	TypeErrorr   r%   r&   subOidr   tupleOfIntss        r(   r   zObjectIdentifier.prettyIni  sf   e-.<s#e|'':?AXAXZ]ZfZfZhijZkl C8HSfFc&kSTT	5 PFaKV PQK {s5z)%I`I` abb# T '':?AXAXZ]^  !QI& 	##6;T^^=T=TVYZ 	`   8D" DD%D" -	E* 6
E%E%E* D" "	E"+2EE"%E* *F092F++F0c                 \    dj                  |D cg c]  }t        |       c}      S c c}w Nr  r1  r   r%   r&   r   s      r(   r   zObjectIdentifier.prettyOut  #    xx/AQ/00/   )Nr   r   r   r   r
   r   r   r   r   r   r   r   r   r   r"   r   r   rC   rE   ry  r   r   r   rg  r  r  r   r   r   r)   r(   r   r     s    (X S^^%%s':':DAF 5*446K   **,F//
 "!$)(c:1r)   r   c                      e Zd ZdZ ej
                   ej                  ej                  ej                  d            Z	 e
j                         Zej                  j                         Zd Zd Zd Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zy)RelativeOIDa[  Create |ASN.1| schema or value object.
    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    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 :class:`str` literal or |ASN.1| object.
        If `value` is not given, schema object will be created.
    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). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.
    Raises
    ------
    ~pyasn1.error.ValueConstraintError, ~pyasn1.error.PyAsn1Error
        On constraint violation or bad initializer.
    Examples
    --------
    .. code-block:: python
        class RelOID(RelativeOID):
            '''
            ASN.1 specification:
            id-pad-null RELATIVE-OID ::= { 0 }
            id-pad-once RELATIVE-OID ::= { 5 6 }
            id-pad-twice RELATIVE-OID ::= { 5 6 7 }
            '''
        id_pad_null = RelOID('0')
        id_pad_once = RelOID('5.6')
        id_pad_twice = id_pad_once + (7,)
       c                 >    | j                  | j                  |z         S r+   r,   r   s     r(   rC   zRelativeOID.__add__  r1   r)   c                 >    | j                  || j                  z         S r+   r,   r   s     r(   rE   zRelativeOID.__radd__  r4   r)   c                     | j                   S r+   r   rl   s    r(   ry  zRelativeOID.asTuple  rz  r)   c                 ,    t        | j                        S r+   r   rl   s    r(   r   zRelativeOID.__len__  rn   r)   c                     |j                   t        u r| j                  | j                  |         S | j                  |   S r+   r_  r`  s     r(   r   zRelativeOID.__getitem__  ra  r)   c                 ,    t        | j                        S r+   rc  rl   s    r(   r   zRelativeOID.__iter__  re  r)   c                     || j                   v S r+   r   r/   s     r(   rg  zRelativeOID.__contains__  rh  r)   c                 8    | j                   j                  |      S r+   r  r  s     r(   r  zRelativeOID.index  r  r)   c                 b    t        |       }|t        |      k  r| j                  d| |d| k(  ryy)ap  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`
            :obj:`True` if this |ASN.1| object is a parent (e.g. prefix) of the other |ASN.1| object
            or :obj:`False` otherwise.
        NTFr   r  s      r(   r  zRelativeOID.isPrefixOf  s6     IE
?{{2A%)+r)   c           	      f   t        |t              rt        |      S t        |t              rd|v rGt	        j
                  d|d| j                  j                  dt        j                         d         	 t        |j                  d      D cg c]  }|st        |       c}      S 	 t        |D cg c]  }|dk\  s	t        |       c}      }t        |      t        |      k(  r|S t	        j
                  d|d| j                  j                        c c}w # t        $ r7}t	        j
                  d|d| j                  j                  d|      d }~ww xY wc c}w # t        t        f$ r7}t	        j
                  d|d| j                  j                  d|      d }~ww xY w)Nr  zMalformed RELATIVE-OID r  r  r   r  r   )r+  r  r   r   r   r   r   r   r  r  r-  rk   r   r  r   r  s        r(   r   zRelativeOID.prettyIn  se   e[)<s#e|''=BDNND[D[]`]i]i]klm]no C8HSfFc&kSTT	5 PFaKV PQK {s5z)UDNNLcLc dee# T ''=BDNND[D[]`a  !QI& 	##9>@W@WY\] 	r  c                 \    dj                  |D cg c]  }t        |       c}      S c c}w r  r  r  s      r(   r   zRelativeOID.prettyOut  r  r  Nr  r   r)   r(   r  r    s     H S^^%%s':':DAF 5*446K   **,F//
 "!$)$f:1r)   r  c                   r   e Zd ZdZdZ	  ed      Z ed      ZeefZ e
j                   e
j                  e
j                  e
j                  d            Z ej"                         Zej(                  j+                         Zed        Zd Zd/d	Zed
        Zed        Zed        Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d0dZ'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1d/d Z2d! Z3d" Z4d# Z5d$ Z6d% Z7d& Z8d' Z9d( Z:d) Z;d* Z<ej(                  jz                  Z=d+ Z>d, Z?d- Z@d. ZAy# e	$ r
 dxZZdZY w xY w)1r   ab  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    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 :class:`float` instance or |ASN.1| object.
        If `value` is not given, schema object will be created.

    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). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

    Raises
    ------
    ~pyasn1.error.ValueConstraintError, ~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                 V    | \  }}}|r|dz  dk(  r|dz  }|dz  }|r	|dz  dk(  r|||fS )N
   r   r   r   )r&   mr8  es       r(   __normalizeBase10zReal.__normalizeBase10Q  sH    1aAFaKGAFA AFaK !Qwr)   c                    t        |t              rt        |      dk(  rt        |d   t        t        f      r&t        |d   t              rt        |d   t              st        j                  d|      t        |d   t              r"| j                  r|d   | j                  v r|d   S |d   dvrt        j                  d|d         |d   dk(  r| j                  |      }|S t        |t              r| j                  |ddf      S t        |t              st        |t              r~t        |t              r	 t	        |      }| j                  r|| j                  v r|S d}t        |      |k7  r|dz  }|dz  }t        |      |k7  r| j                  t        |      d|f      S t        |t              rt        |      S t        j                  d	|      # t        $ r t        j                  d	|      w xY w)
Nr   r   r   r   zLame Real value syntax: )r   r  z Prohibited base for Real value: r  zBad real value syntax: )r+  r   r   rk   rq   r   r   _inf_Real__normalizeBase10r   r   r   )r%   r&   r  s      r(   r   zReal.prettyInY  s   eU#E
auQx#u6"58S1"58S1''(OPP58U+II%(dii"7QxQxw&''<A!HF  Qx2~..u5Ls#))5"a.99u%E3)?%%!%LE
 yyUdii/%jE)RKEFA %jE) --s5z2q.ABBt$<+02
 	
 " ++7<> s   =G "G?c                 V    	 | j                  t        |             S # t        $ r Y yw xY w)Nz
<overflow>)r   rq   OverflowError)r%   rR  s     r(   rT  zReal.prettyPrint  s,    	 >>%+.. 	 	 s    	((c                 4    | j                   | j                  k(  S )zIndicate PLUS-INFINITY object value

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

        )r.   _plusInfrl   s    r(   	isPlusInfzReal.isPlusInf  s     {{dmm++r)   c                 4    | j                   | j                  k(  S )zIndicate MINUS-INFINITY object value

        Returns
        -------
        : :class:`bool`
            :obj:`True` if calling object represents minus infinity
            or :obj:`False` otherwise.
        )r.   	_minusInfrl   s    r(   
isMinusInfzReal.isMinusInf  s     {{dnn,,r)   c                 2    | j                   | j                  v S r+   )r.   r  rl   s    r(   isInfz
Real.isInf  s    {{dii''r)   c                 <    | j                  t        |       |z         S r+   r-   rq   r/   s     r(   rC   zReal.__add__      zz%+-..r)   c                     | |z   S r+   r   r/   s     r(   rE   zReal.__radd__  r   r)   c                 <    | j                  t        |       |z        S r+   r  r/   s     r(   rK   zReal.__mul__  r  r)   c                     | |z  S r+   r   r/   s     r(   rM   zReal.__rmul__  r   r)   c                 <    | j                  t        |       |z
        S r+   r  r/   s     r(   rG   zReal.__sub__  r  r)   c                 <    | j                  |t        |       z
        S r+   r  r/   s     r(   rI   zReal.__rsub__      zz%%+-..r)   c                 <    | j                  t        |       |z        S r+   r  r/   s     r(   rO   zReal.__mod__  r  r)   c                 <    | j                  |t        |       z        S r+   r  r/   s     r(   rQ   zReal.__rmod__  r  r)   c                 L    | j                  t        t        |       ||            S r+   r-   rT   rq   rU   s      r(   rW   zReal.__pow__  s    zz#eDk5&9::r)   c                 J    | j                  t        |t        |                   S r+   r  r/   s     r(   rY   zReal.__rpow__  s    zz#eU4[122r)   c                 <    | j                  t        |       |z        S r+   r  r/   s     r(   r`   zReal.__truediv__  r  r)   c                 <    | j                  |t        |       z        S r+   r  r/   s     r(   rb   zReal.__rtruediv__  r  r)   c                 <    | j                  t        |       |z        S r+   r  r/   s     r(   rf   zReal.__divmod__  s    zz%+.//r)   c                 <    | j                  |t        |       z        S r+   r  r/   s     r(   rh   zReal.__rdivmod__  s    zz%5;.//r)   c                 *    t        t        |             S r+   )rk   rq   rl   s    r(   rm   zReal.__int__  s    5;r)   c                     | j                   | j                  v r| j                   S t        | j                   d   t        | j                   d   | j                   d         z        S )Nr   r   r   )r.   r  rq   rT   rl   s    r(   rr   zReal.__float__  sP    ;;$))#;;AT[[^T[[^!DD r)   c                 H    | j                  t        t        |                   S r+   )r-   ru   rq   rl   s    r(   rv   zReal.__abs__  s    zz#eDk*++r)   c                 8    | j                  t        |             S r+   r  rl   s    r(   rz   zReal.__pos__      zz5;,''r)   c                 8    | j                  t        |              S r+   r  rl   s    r(   r}   zReal.__neg__  r  r)   c                 V    t        t        |       |      }|r| j                  |      S |S r+   )r   rq   r-   r   s      r(   r   zReal.__round__  s(    %+q!::a= Hr)   c                 \    | j                  t        j                  t        |                   S r+   )r-   r   r   rq   rl   s    r(   r   zReal.__floor__      zz$**U4[122r)   c                 \    | j                  t        j                  t        |                   S r+   )r-   r   r   rq   rl   s    r(   r   zReal.__ceil__  s    zz$))E$K011r)   c                 \    | j                  t        j                  t        |                   S r+   )r-   r   r   rq   rl   s    r(   r   zReal.__trunc__  r  r)   c                     t        |       |k  S r+   rq   r/   s     r(   r   zReal.__lt__      T{U""r)   c                     t        |       |k  S r+   r  r/   s     r(   r   zReal.__le__      T{e##r)   c                     t        |       |k(  S r+   r  r/   s     r(   r   zReal.__eq__  r  r)   c                     t        |       |k7  S r+   r  r/   s     r(   r   zReal.__ne__  r  r)   c                     t        |       |kD  S r+   r  r/   s     r(   r   zReal.__gt__  r  r)   c                     t        |       |k\  S r+   r  r/   s     r(   r   zReal.__ge__  r  r)   c                 *    t        t        |             S r+   )boolrq   rl   s    r(   __bool__zReal.__bool__  s    E$K  r)   c                 z    | j                   | j                  v rt        j                  d      | j                   |   S )Nz Invalid infinite value operation)r.   r  r   r   r%   idxs     r(   r   zReal.__getitem__
  s3    ;;$))###$FGG;;s##r)   c                     | j                   S r+   )r  rl   s    r(   isPlusInfinityzReal.isPlusInfinity      ~~r)   c                     | j                   S r+   )r  rl   s    r(   isMinusInfinityzReal.isMinusInfinity  s    r)   c                     | j                   S r+   )r  rl   s    r(   
isInfinityzReal.isInfinity  s    zzr)   r   r+   )Br   r   r   r   
binEncBaserq   r  r  r  r   r
   r   r   r   r   r   r   r   r   r   r"   r   r   rp  r  r   rT  propertyr  r  r  rC   rE   rK   rM   rG   rI   rO   rQ   rW   rY   r`   rb   rf   rh   rm   rr   rv   rz   r}   r   r   r   r   r   r   r   r   r   r   r  r   r   r  r  r  r   r)   r(   r   r     s   )T J<&M	" S^^%%s':':DAF 5*446K   **,F &
P  
, 
, 	- 	- ( (//////;3//00 ,((323#$$$#$! ""++H$w  ##9s   D' 'D65D6r   c                       e Zd ZdZ ej
                   ej                  ej                  ej                  d            Z	 e
j                         Zej                         Z ej"                         Zy)r   a  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    objects are immutable and duck-type Python :class:`int` objects.

    Keyword Args
    ------------
    value: :class:`int`, :class:`str` or |ASN.1| object
        Python :class:`int` or :class:`str` literal or |ASN.1| object.
        If `value` is not given, schema object will be created.

    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). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

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

    Raises
    ------
    ~pyasn1.error.ValueConstraintError, ~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)r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r	   r   r!   r   r)   r(   r   r     sl    /f S^^%%s':':DAF 5*446K  F '(&&(Kr)   r   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	dd	Z
d
 ZddZd Zd Zd ZedfdZedddfdZed        Zed        Zd Zd ZddZddZed        Zed        Zy)r   a<  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.ConstructedAsn1Type`,
    its 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). Constraints
        verification for |ASN.1| type can only occur on explicit
        `.isInconsistent` call.

    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                     |r2t        d|      D ]#  \  }}||v rt        j                  d      ||d<   % t        | _        t        j                  j                  | fi | y )N)componentTyper   r   z*Conflicting positional and keyword params!r  )zipr   r   r   _componentValuesr   ConstructedAsn1Typer#   )r%   argsr'   keyr&   s        r(   r#   zSequenceOfAndSetOfBase.__init__  sk    ! #2379 0
U&=++,XYY*/'	0 !(  ))$9&9r)   c                 r    	 | j                  |      S # t        j                  $ r}t        |      d }~ww xY wr+   )getComponentByPositionr   r   r   r%   r  r   s      r(   r   z"SequenceOfAndSetOfBase.__getitem__  s8    	"..s33   	"S/!	"s    616c                 v    	 | j                  ||       y # t        j                  $ r}t        |      d }~ww xY wr+   )setComponentByPositionr   r   r   r%   r  r&   r   s       r(   __setitem__z"SequenceOfAndSetOfBase.__setitem__  s7    	"''U3   	"S/!	"s    838c                 b    | j                   t        u rd}nt        | j                         }|| |<   y r   )r  r   r   )r%   r&   poss      r(   rW  zSequenceOfAndSetOfBase.append  s0      G+C d++,CS	r)   c                 f    t        | j                  j                               j                  |      S r+   )r0  r  valuesr  r/   s     r(   r  zSequenceOfAndSetOfBase.count  s'    D))002399%@@r)   c                 h    |D ]  }| j                  |        | j                  t        u ri | _        y y r+   )rW  r  r   )r%   r  r&   s      r(   extendzSequenceOfAndSetOfBase.extend  s:     	EKK	   G+$&D! ,r)   Nc                     |t        |       }t        | j                  j                          \  }}t	        |      }	 ||j                  |||         S # t        j                  $ r}t        |      d }~ww xY wr+   )	r   r  r  itemsr0  r  r   r   r   )r%   r&   startstopr   r  r   s          r(   r  zSequenceOfAndSetOfBase.index  su    <t9Dt44::<= f	"6<<ud;<<   	"S/!	"s   A A6&A11A6c                 8    | j                   j                          y r+   )r  reverserl   s    r(   r  zSequenceOfAndSetOfBase.reverse  s    %%'r)   c           	      ~    t        t        t        | j                  j	                         ||                  | _        y )N)r  r  )dict	enumeratesortedr  r  )r%   r  r  s      r(   sortzSequenceOfAndSetOfBase.sort  s4     $fT2299;!$g7 8!9r)   c                 p    | j                   t        u s| j                   syt        | j                         dz   S )Nr   r   )r  r   r   rl   s    r(   r   zSequenceOfAndSetOfBase.__len__  s1      G+43H3H4(()A--r)   c              #   f   K   t        dt        |             D ]  }| j                  |        y wr   )r   r   r  r  s     r(   r   zSequenceOfAndSetOfBase.__iter__  s1     CI& 	3C--c22	3s   /1c                    | j                   j                         D ]k  \  }}|t        ust        |t        j
                        r#|j                  ||j                  |             L|j                  ||j                                m y NcloneValueFlag)r  r  r   r+  r   r  r  r-   r%   myCloner  r  componentValues        r(   _cloneComponentValuesz,SequenceOfAndSetOfBase._cloneComponentValues  s{    #'#8#8#>#>#@ 	PCW,nd.F.FG22^111P 2238L8L8NO	Pr)   Tc                    t        |t              rAt        t        t	        |                   }||   D cg c]  }| j                  |||       c}S |dk  r(t	        |       |z   }|dk  rt        j                  d      	 | j                  |   }|t        u s|j                  r|S |S c c}w # t        t        j                  f$ r) |s|cY S | j                  |       | j                  |   }Y ^w xY w)a2  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 :obj:`True` (default), inner component will be automatically instantiated.
            If :obj:`False` either existing component or the :class:`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)
        r   &SequenceOf/SetOf index is out of range)r+  r   r   r   r   r  r   r   r  r   r  r   isValue)r%   r  defaultinstantiater   subidxr  s          r(   r  z-SequenceOfAndSetOfBase.getComponentByPosition  s    D c5!E#d),-G")#,0 //M 0 0 7d)c/CQw''<> >		8!2237N g!7!7!!N/0 %++, 	8'',!2237N	8s   B' B, ,C. C.-C.c                 h   t        |t              rZt        t        t	        |                   }|xr ||   d   xs d}t        |      D ]  \  }}	| j                  ||z   |	|||        | S |dk  r(t	        |       |z   }|dk  rt        j                  d      | j                  }
| j                  t        u ri }n| j                  }|j                  |t              }|t        u r2|
|
j                         }n/|t        u r&t        j                  d      t        |t        j                        s|
-t        |
t        j                         r|
j                  |      }n|t        ur-t        |t        j                         r|j                  |      }nt        j                  d|d|       |
v|s|rr| j"                  xr |
j$                  xs |
j&                  } |||xr ||xr |      s8|
j(                  t*        j(                  k7  rt        j                  d|d|
      |||<   || _
        | 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.
            If `value` is not given, schema object will be set as a component.

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

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

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

        Returns
        -------
        self

        Raises
        ------
        ~pyasn1.error.ValueConstraintError, ~pyasn1.error.PyAsn1Error
            On constraint violation or bad initializer
        IndexError
            When idx > len(self)
        r   r   Component type not definedr&   zNon-ASN.1 value z! and undefined component type at %Component value is tag-incompatible:  vs )r+  r   r   r   r   r  r  r   r   r  r  r   getr-   r   Asn1Itemr"   strictConstraintsisSameTypeWithisSuperTypeOfr   r   )r%   r  r&   verifyConstraints	matchTagsmatchConstraintsr   startIdxsubIdxsubValuer  componentValuescurrentValuesubtypeCheckers                 r(   r  z-SequenceOfAndSetOfBase.setComponentByPosition>  s@   X c5!E#d),-G273<?7aH$-e$4 1 ++v%x1B/11 K7d)c/CQw''<> > **  G+ O #33O&**38G(%++-(''(DEEE4==1)}d.A.AB%++%+8g-|T-@-@A$***7 ''%*D23 3 &I9I** 1!000!// 
 "%):)Hy"3"H8HJ !''3::5++ %}67 7  % /r)   c                 H    | j                   | j                   j                  S y r+   )r  tagMaprl   s    r(   componentTagMapz&SequenceOfAndSetOfBase.componentTagMap  s%    )%%,,, *r)   c                 l    t        | j                        D cg c]  }| j                  |    c}S c c}w r+   )r  r  r  s     r(   
componentsz!SequenceOfAndSetOfBase.components  s:     "$"7"78: %%c* : 	: :s   1c                     i | _         | S )zRemove all components and become an empty |ASN.1| value object.

        Has the same effect on |ASN.1| object as it does on :class:`list`
        built-in.
        r  rl   s    r(   clearzSequenceOfAndSetOfBase.clear  s     !#r)   c                     t         | _        | S zRemove all components and become a |ASN.1| schema object.

        See :meth:`isValue` property for more information on the
        distinction between value and schema objects.
        )r   r  rl   s    r(   resetzSequenceOfAndSetOfBase.reset  s     !(r)   c                     |dz  }| j                   j                  dz   }| j                  s|S t        |       D ];  \  }}|d|z  z  }|t        u r| j
                  |dz  }(||j                  |      z  }= |S )Nr   :
 z<empty>)r   r   r!  r  r   r  rT  r%   rR  representationr  r  s        r(   rT  z"SequenceOfAndSetOfBase.prettyPrint  s    
0058||!!#,T? 	DCcEk)N')&&2)+."<"<U"CC	D r)   c                     |dz  }| j                   d| j                  j                  d}| j                  &|d|z  z  }|| j                  j	                  |      z  }|dz   d|dz
  z  z   dz   S )Nr    ->  {
rE  
})r   r   r   r  prettyPrintType)r%   rR  rG  s      r(   rM  z&SequenceOfAndSetOfBase.prettyPrintType  sv    
+/;;8O8OP)cEk)Nd00@@GGN$seai'883>>r)   c                     | j                   t        u ryt        | j                         t        |       k7  ry| j                   j                         D ]  }|t        u s|j                  r y y)ar  Indicate that |ASN.1| object represents ASN.1 value.

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

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

        Returns
        -------
        : :class:`bool`
            :obj:`False` if object represents just ASN.1 schema.
            :obj:`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  s     r(   r!  zSequenceOfAndSetOfBase.isValue  se    6   G+t$$%T2"33::< 	N(0F0F	 r)   c                 4   | j                   t        u s| j                  sy| j                  t        u ryi }| j                  j	                         D ]  \  }}|t        u r|||<    	 | j                  |       y# t
        j                  $ r}|cY d}~S d}~ww xY wa  Run necessary checks to ensure |ASN.1| object consistency.

        Default action is to verify |ASN.1| object against constraints imposed
        by `subtypeSpec`.

        Raises
        ------
        :py:class:`~pyasn1.error.PyAsn1tError` on any inconsistencies found
        FTN)r  r   r   r  r  r   r   )r%   mappingr  r&   r   s        r(   isInconsistentz%SequenceOfAndSetOfBase.isInconsistent
  s     (0@0@  G+//557 	!JC GCL	!	W%
     	J	s   &A8 8BBBB)r   NNFr   )r   r   r   r   r#   r   r  rW  r  r	  r  r  r  r   r   r  r   r  r  r  r:  r<  r?  rB  rT  rM  r!  rS  r   r)   r(   r   r   c  s    !D:""A'"(9
.3P 3:t [z 1815)-04m^ - - : :"? $ $L    r)   r   c                       e Zd Zej                  Z ej                   ej                  ej                  ej                  d            Z
dZ ej                         Zej                         Zy)r   r  Nr   r   r   r   r   r
   r   r   r   tagFormatConstructedr   r  r   r   r   r   r   r   r)   r(   r   r   -  f    $,,G
 S^^%%s'?'?FF M
 5*446K $--/Fr)   r   c                       e Zd Zej                  Z ej                   ej                  ej                  ej                  d            Z
dZ ej                         Zej                         Zy)r      NrV  r   r)   r(   r   r   D  rX  r)   r   c                       e Zd ZdZ ej
                         Z G d de      Zd Z	d Z
d Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zed        Zd ZedfdZedddfdZedfdZedddfdZed        Zed        ZddZddZ d Z!d Z"d Z#y) r   a  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.ConstructedAsn1Type`,
    its 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).  Constraints
        verification for |ASN.1| type can only occur on explicit
        `.isInconsistent` call.

    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                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)SequenceAndSetBase.DynamicNamesz9Fields names/positions mapping for component-less objectsc                      i | _         i | _        y r+   _keyToIdxMap_idxToKeyMaprl   s    r(   r#   z(SequenceAndSetBase.DynamicNames.__init__  s     "D "Dr)   c                 ,    t        | j                        S r+   )r   r`  rl   s    r(   r   z'SequenceAndSetBase.DynamicNames.__len__  s    t(())r)   c                 >    || j                   v xs || j                  v S r+   r_  r%   items     r(   rg  z,SequenceAndSetBase.DynamicNames.__contains__  s#    4,,,I8I8I0IIr)   c                 R      fdt        t         j                              D        S )Nc              3   <   K   | ]  }j                   |     y wr+   )ra  )rP  r  r%   s     r(   rQ  z;SequenceAndSetBase.DynamicNames.__iter__.<locals>.<genexpr>  s     TsD%%c*Ts   )r   r   ra  rl   s   `r(   r   z(SequenceAndSetBase.DynamicNames.__iter__  s    TeC@Q@Q<R6STTr)   c                 ^    	 | j                   |   S # t        $ r | j                  |   cY S w xY wr+   )r`  r   ra  rd  s     r(   r   z+SequenceAndSetBase.DynamicNames.__getitem__  s8    /((.. /((../s    ,,c                 f    	 | j                   |   S # t        $ r t        j                  d      w xY w)NzType position out of range)ra  r   r   r   r  s     r(   getNameByPositionz1SequenceAndSetBase.DynamicNames.getNameByPosition  s<    F((-- F''(DEEFs    0c                 n    	 | j                   |   S # t        $ r t        j                  d|d      w xY w)NName 
 not found)r`  r   r   r   )r%   r3  s     r(   getPositionByNamez1SequenceAndSetBase.DynamicNames.getPositionByName  s>    G((.. G''t(EFFGs    #4c                 L    || j                   d|z  <   d|z  | j                  |<   y )Nzfield-%dr_  r  s     r(   addFieldz(SequenceAndSetBase.DynamicNames.addField  s,    25Dj3./%/#%5Dc"r)   N)r   r   r   r   r#   r   rg  r   r   rj  rn  rp  r   r)   r(   DynamicNamesr]    s1    G	#	*	J	U	/	F	G	6r)   rq  c                     t        j                  j                  | fi | t        | j                        | _        | j
                  rg | _        nt        | _        | j
                  xs | j                         | _	        y r+   )
r   r  r#   r   r  _componentTypeLenr  r   rq  _dynamicNames)r%   r'   s     r(   r#   zSequenceAndSetBase.__init__  sc      ))$9&9!$T%7%7!8!!$&D!$+D!!33Jt7H7H7Jr)   c                    t        |t              r	 | j                  |      S 	 | j                  |      S # t        j                  $ r}t        |      d }~ww xY w# t        j                  $ r}t        |      d }~ww xY wr+   )r+  r   getComponentByNamer   r   r   r  r   r  s      r(   r   zSequenceAndSetBase.__getitem__  s{    c3$..s33&22377 $$ $sm#$ $$ & o%&s,   5 A AAAA>.A99A>c                 
   t        |t              r	 | j                  ||       y 	 | j                  ||       y # t        j                  $ r}t        |      d }~ww xY w# t        j                  $ r}t        |      d }~ww xY wr+   )r+  r   setComponentByNamer   r   r   r  r   r  s       r(   r  zSequenceAndSetBase.__setitem__  sy    c3$''U3&++C7 $$ $sm#$ $$ & o%&s,   9 A AAAB2A==Bc                 R    | j                   r|| j                  v S || j                  v S r+   )rs  r  rt  r%   r  s     r(   rg  zSequenceAndSetBase.__contains__  s-    !!$,,,,$,,,,r)   c                 ,    t        | j                        S r+   )r   r  rl   s    r(   r   zSequenceAndSetBase.__len__  s    4(())r)   c                 H    t        | j                  xs | j                        S r+   )rd  r  rt  rl   s    r(   r   zSequenceAndSetBase.__iter__  s    D&&<$*<*<==r)   c              #   |   K   t        | j                  xs t        | j                              D ]	  }| |     y wr+   )r   rs  r   rt  r  s     r(   r  zSequenceAndSetBase.values  s9     //J3t7I7I3JK 	Cs)O	s   :<c                     t        |       S r+   )rd  rl   s    r(   keyszSequenceAndSetBase.keys  s    Dzr)   c              #      K   t        | j                  xs t        | j                              D ]E  }| j                  r!| j                  |   j
                  | |   f 0| j                  |   | |   f G y wr+   )r   rs  r   rt  r  r3  r  s     r(   r  zSequenceAndSetBase.items  ss     //J3t7I7I3JK 	9C%%((-22DI==((-tCy88		9s   A6A8c                 @    |D ]
  \  }}|| |<    |D ]
  }||   | |<    y r+   r   )r%   	iterValuemappingValuekrZ  s        r(   updatezSequenceAndSetBase.update  s:     	DAqDG	 	&A"1oDG	&r)   c                 >    g | _         | j                         | _        | S )zRemove all components and become an empty |ASN.1| value object.

        Has the same effect on |ASN.1| object as it does on :class:`dict`
        built-in.
        )r  rq  rt  rl   s    r(   r?  zSequenceAndSetBase.clear	  s"     !#!..0r)   c                 F    t         | _        | j                         | _        | S rA  )r   r  rq  rt  rl   s    r(   rB  zSequenceAndSetBase.reset	  s"     !(!..0r)   c                     | j                   S r+   r>  rl   s    r(   r<  zSequenceAndSetBase.components	  s    $$$r)   c                 0   | j                   t        u ry t        | j                         D ]k  \  }}|t        ust        |t        j
                        r#|j                  ||j                  |             L|j                  ||j                                m y r  )r  r   r  r+  r   r  r  r-   r  s        r(   r  z(SequenceAndSetBase._cloneComponentValues	  s      G+#,T-B-B#C 	PCW,nd.F.FG22^111P 2238L8L8NO	Pr)   Tc                     | j                   r| j                  j                  |      }n	 | j                  j                  |      }| j                  |||      S # t        $ r t        j                  d|d      w xY w)ap  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 :obj:`True` (default), inner component will be automatically
            instantiated.
            If :obj:`False` either existing component or the :class:`NoValue`
            object will be returned.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            Instantiate |ASN.1| component type or return existing
            component value
        rl  rm  r"  r#  )rs  r  rn  rt  r   r   r   r  )r%   r3  r"  r#  r  s        r(   rv  z%SequenceAndSetBase.getComponentByName'	  s    8 !!$$66t<CG((::4@
 **3[*YY  G''t(EFFGs   A #A<c                     | j                   r| j                  j                  |      }n	 | j                  j                  |      }| j                  |||||      S # t        $ r t        j                  d|d      w xY w)a  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.
            If `value` is not given, schema object will be set as a component.

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

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

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

        Returns
        -------
        self
        rl  rm  )rs  r  rn  rt  r   r   r   r  )r%   r3  r&   r/  r0  r1  r  s          r(   rx  z%SequenceAndSetBase.setComponentByNameN	  s    B !!$$66t<CG((::4@
 **)96F
 	
  G''t(EFFGs   A #A=c                 2   	 | j                   t        u rt        }n| j                   |   }|s|t        u s|j                  s|S |S |t        u r| j	                  |       | j                   |   }|t        u s|j                  r|S |S # t        $ r	 t        }Y kw xY w)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 :obj:`True` (default), inner component will be automatically
            instantiated.
            If :obj:`False` either existing component or the :class:`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)
        )r  r   r   r!  r  )r%   r  r"  r#  r  s        r(   r  z)SequenceAndSetBase.getComponentByPosition|	  s    H	%$$/!( "&!6!6s!;
 (0F0F%%W$'',..s3g!7!7!!N#  	%$N	%s   (B BBc                    | j                   }| j                  }| j                  t        u rg }n| j                  }	 ||   }	|t        u rm|rM|j                  |      }t        |t        j                        r|j                  ||   j                        }n|	t        u rt        j                  d      t        |t        j                        s|rk|j                  |      }
t        |
t        j                        r|
j                  |      }nt        j                  d|j                  j                   z        |	t        ur-t        |	t        j                        r|	j                  |      }nt        j                  d|j                  j                   z        |s|s|r|r}|j                  |      }
|
t        urd| j"                  xr |
j$                  xs |
j&                  } |||xr ||xr |      s*||   j(                  st        j                  d|d|      |s|| j*                  v r|||<   nPt-        |      |k(  r-|j/                  |       | j*                  j1                  |       nt        j                  d	      || _        | S # t        $ r0 t        }	|r$||k  rt        j                  d      t        g|z  }Y w xY w)
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 (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.
            If `value` is not given, schema object will be set as a component.

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

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

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

        Returns
        -------
        self
        zcomponent index out of ranger  r&  r'  z%s can cast only scalar valuesz%s undefined component typer(  r)  zComponent index out of range)r  rs  r  r   r   r   r   getTypeByPositionr+  r   r  r-   isDefaultedr+  r"   r   r   r,  r-  r.  openTypert  r   rW  rp  )r%   r  r&   r/  r0  r1  r  componentTypeLenr5  r6  subComponentTyper7  s               r(   r  z)SequenceAndSetBase.setComponentByPosition	  s   H **11  G+ O #33O		?*3/L G%77<eT%=%=>!KK}S7I7U7UKVE(''(DEEE4==1#0#B#B3#G .0C0CD,222?E  ++,L}OfOfOoOo,oppW,L$J]J]1^$***7 ''(EH_H_HhHh(hii I1A,>>sCw."&"8"8 #B"2"A"A#A"2"@"@  &e->-L9&7&L<LN(-66#//chjw0xyysd&8&88#(OC !S(""5)'', ##$BCC /s  	?"L#c)++,JKK#*).>">	?s   J 5K
	K
c                 h   | j                   t        u ry| j                  }|rjt        |j                        D ]Q  \  }}|j
                  s|j                  r| j                   s y| j                   |   }|t        u s|j                  rQ y y| j                   D ]  }|t        u s|j                  r y y)a  Indicate that |ASN.1| object represents ASN.1 value.

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

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

        Returns
        -------
        : :class:`bool`
            :obj:`False` if object represents just ASN.1 schema.
            :obj:`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).

        It is sufficient for |ASN.1| objects to have all non-optional and non-defaulted
        components being value objects to be considered as a value objects as a whole.
        In other words, even having one or more optional components not turned into
        value objects, |ASN.1| object is still considered as a value object. Defaulted
        components are normally value objects by default.
        FT)r  r   r  r  
namedTypesr  
isOptionalr!  )r%   r  r  r  r  s        r(   r!  zSequenceAndSetBase.isValueE
  s    D   G+**)2=3K3K)L 	!%%#//3C3N3N,, !%!6!6s!;!W,N4J4J 	!  	 #'"7"7 !!W,N4J4J ! r)   c                 `   | j                   t        u s| j                  sy| j                  t        u ryi }t	        | j                        D ].  \  }}|t        u r| j                   j                  |      }|||<   0 	 | j                  |       y# t        j                  $ r}|cY d}~S d}~ww xY wrQ  )r  r   r   r  r  rj  r   r   )r%   rR  r  r&   r3  r   s         r(   rS  z!SequenceAndSetBase.isInconsistent
  s     (0@0@  G+#D$9$9: 	"JC%%77<D!GDM	"	W%
     	J	s   <B B-!B("B-(B-c                 x   |dz  }| j                   j                  dz   }t        | j                        D ]  \  }}|t        us|j
                  s|d|z  z  }| j                  r|| j                  j                  |      z  }n|| j                  j                  |      z  }|d|j                  |      d} |S )zReturn an object representation string.

        Returns
        -------
        : :class:`str`
            Human-friendly object representation.
        r   rD  rE  =rK  )
r   r   r  r  r   r!  r  rj  rt  rT  rF  s        r(   rT  zSequenceAndSetBase.prettyPrint
  s     	
0058#,T-B-B#C 		CW,1G1G#+-%%"d&8&8&J&J3&OON"d&8&8&J&J3&OON"N$>$>u$E"		 r)   c                    |dz  }| j                   d| j                  j                  d}t        | j                  j                         xs | j                        D ]s  \  }}|d|z  z  }| j                  r"|d| j                  j                  |      z  z  }n!|d| j                  j                  |      z  z  }|d|j                  |      d}u |dz   d|dz
  z  z   dz   S )	Nr   rI  rJ  rE  z"%s"z = rK  rL  )
r   r   r   r  r  r  r  rj  rt  rM  )r%   rR  rG  r  r  s        r(   rM  z"SequenceAndSetBase.prettyPrintType
  s    
+/;;8O8OP"+D,>,>,E,E,G,`4K`K`"a 	CcEk)N!!&4+=+=+O+OPS+T"TT&4+=+=+O+OPS+T"TT = =e DN	 $seai'883>>r)   c                     | S r+   r   rl   s    r(   setDefaultComponentsz'SequenceAndSetBase.setDefaultComponents
      r)   c                 4    | j                   r| j                  S y r+   )rs  r  rl   s    r(   getComponentTypez#SequenceAndSetBase.getComponentType
  s    !!%%% "r)   c                 N    | j                   r| j                  |   j                  S y r+   )rs  r  r3  r  s     r(   rj  z$SequenceAndSetBase.getNameByPosition
  s'    !!%%c*/// "r)   Nr   )$r   r   r   r   r   
NamedTypesr  objectrq  r#   r   r  rg  r   r   r  r  r  r  r?  rB  r  r<  r  r   rv  rx  r  r  r!  rS  rT  rM  r  r  rj  r   r)   r(   r   r   [  s   *Z )I((*M&6v &6RK&"&"-*>
9& % %P 07D %ZN .5-1%),0,
\ 3:t \| 1815)-04iV 7 7r " "H,? &0r)   r   c                      e Zd Zej                  Z ej                   ej                  ej                  ej                  d            Z
 ej                         Z ej                         Zej#                         Zd Zd Zy)r   r  c                 R    | j                   r| j                   j                  |      S y r+   )r  getTagMapNearPositionr  s     r(   getComponentTagMapNearPositionz'Sequence.getComponentTagMapNearPosition
  s'    %%;;C@@ r)   c                 V    | j                   r| j                   j                  ||      S |S r+   )r  getPositionNearType)r%   r   r  s      r(   getComponentPositionNearTypez%Sequence.getComponentPositionNearType
  s)    %%99&#FFJr)   N)r   r   r   r   r   r
   r   r   r   rW  r   r   r   r   r   r  r  r   r   r  r  r   r)   r(   r   r   
  s|     ((G
 S^^%%s'?'?FF 5*446K )I((*M  ))+FAr)   r   c                   0   e Zd Zej                  Z ej                   ej                  ej                  ej                  d            Z
 ej                         Z ej                         Zej#                         Zd	dZeddfdZeddddfdZed        Zy)
r   rZ  Fc                     | S r+   r   )r%   	innerFlags     r(   getComponentzSet.getComponent  r  r)   Tc                     | j                  | j                  j                  |      ||      }|r"t        |t              r|j                  d      S |S )a8  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 :obj:`True` (default), inner component will be automatically
            instantiated.
            If :obj:`False` either existing component or the :class:`noValue`
            object will be returned.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            a pyasn1 object
        r  Tr  )r  r  getPositionByTyper+  r   r  )r%   r   r"  r#  r  r  s         r(   getComponentByTypezSet.getComponentByType  s\    6 44008 5 
 NC8!...>> "!r)   c                 .   | j                   j                  |      }|rd| j                   j                  |      }|j                  r| j	                  |||||      S | j                  |      }|j                  ||||||      S | j	                  |||||      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.
            If `value` is not given, schema object will be set as a component.

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

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

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

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

        Returns
        -------
        self
        r  )r  r  r  r   r  r  setComponentByType)	r%   r   r&   r/  r0  r1  r  r  r  s	            r(   r  zSet.setComponentByType7  s    H   226: ..@@EM##22 19>N  !% ; ;C @$77E#4iAQ]f 8   ..U-y:J r)   c                 H    | j                   r| j                   j                  S y r+   )r  tagMapUniquerl   s    r(   r:  zSet.componentTagMapn  s"    %%222 r)   NF)r   r   r   r   r   r
   r   r   r   rW  r   r   r  r  r   r   r   r   r   r  r   r  r  r  r:  r   r)   r(   r   r   
  s     ((G
 S^^%%s'?'?FF )I((*M
 5*446K  ))+F 29'+u$"L 07-1%),0%*	5n 3 3r)   r   c                      e Zd ZdZ ej
                         Z ej                         Z	 e
j                   e
j                  dd            Zej                         ZdZd Zd Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Z e!dfdZ"e!dddfdZ#e$d        Z%e$d        Z&ddZ'ddZ(e$d        Z)d Z*d Z+y)r   a  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.ConstructedAsn1Type`,
    its objects are mutable and duck-type Python :class:`list` 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).  Constraints
        verification for |ASN.1| type can only occur on explicit
        `.isInconsistent` call.

    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'
    r   Nc                 ^    | j                   r| j                   | j                     |k(  S t        S r+   r  _currentIdxNotImplementedr   s     r(   r   zChoice.__eq__  -      (()9)9:eCCr)   c                 ^    | j                   r| j                   | j                     |k7  S t        S r+   r  r   s     r(   r   zChoice.__ne__  r  r)   c                 ^    | j                   r| j                   | j                     |k  S t        S r+   r  r   s     r(   r   zChoice.__lt__  -      (()9)9:UBBr)   c                 ^    | j                   r| j                   | j                     |k  S t        S r+   r  r   s     r(   r   zChoice.__le__  r  r)   c                 ^    | j                   r| j                   | j                     |kD  S t        S r+   r  r   s     r(   r   zChoice.__gt__  r  r)   c                 ^    | j                   r| j                   | j                     |k\  S t        S r+   r  r   s     r(   r   zChoice.__ge__  r  r)   c                 ,    t        | j                        S r+   )r  r  rl   s    r(   r  zChoice.__bool__  s    D))**r)   c                 .    | j                   d uxr dxs dS )Nr   r   )r  rl   s    r(   r   zChoice.__len__  s    t+16Q6r)   c                 p    | j                   y|| j                  | j                      j                         k(  S rT  r  r  getNamerz  s     r(   rg  zChoice.__contains__  s6    #d(()9)9:BBDDDr)   c              #      K   | j                   t        | j                  | j                      j                          y wr+   )r  StopIterationr  r  rl   s    r(   r   zChoice.__iter__  s8     #  !1!12::<<s   =?c              #   \   K   | j                   | j                  | j                       y y wr+   )r  r  rl   s    r(   r  zChoice.values  s.     '''(8(899 (s   *,c              #   x   K   | j                   *| j                  | j                      j                          y y wr+   r  rl   s    r(   r  zChoice.keys  s7     '$$T%5%56>>@@ (s   8:c              #      K   | j                   9| j                  | j                      j                         | | j                      f y y wr+   r  rl   s    r(   r  zChoice.items  sG     '$$T%5%56>>@$tGWGWBXXX (s   AA	c                 F    | j                   t        j                  d      y )NComponent not chosen)r  r   r   rl   s    r(   checkConsistencyzChoice.checkConsistency  s%    ###$:;; $r)   c                 d   	 | j                         }t        |t              r|j                  }n|j                  }t        |t
        j                        r#|j                  ||j                  |             y |j                  ||j                                y # t        j                  $ r Y y w xY wr  )r  r+  r   effectiveTagSetr   r   r  r  r-   r   r   )r%   r  r  	componentr   s        r(   r  zChoice._cloneComponentValues  s    	F))+I )V,"22")))T%=%=>**IOO>OJ **69??3DE    		s   B B/.B/Tc                     t         j                  }| j                  | j                  |k7  rt         j                  | |||      S | j                  |   S )Nr  )r   r   r  r  r  )r%   r  r"  r#  r   s        r(   r  zChoice.getComponentByPosition  sZ    ++#t'7'73'>--dC:E . G G $$S))r)   c                     | j                   }t        j                  | |||||       || _         |||k7  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.
            If `value` is not given, schema object will be set as a component.

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

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

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

        Returns
        -------
        self
        )r  r   r  r   r  )r%   r  r&   r/  r0  r1  oldIdxs          r(   r  zChoice.setComponentByPosition  sS    J !!""4e5F	Scd&C-,3D!!&)r)   c                 j    | j                   r| j                   S | j                         }|j                  S )zwReturn a :class:`~pyasn1.type.tag.TagSet` object of the currently initialized component or self (if |ASN.1| is tagged).)r   r  r  )r%   r  s     r(   r  zChoice.effectiveTagSet<  s/     ;;;;))+I,,,r)   c                     | j                   rt        j                  j                  |       S | j                  j
                  S z"Return a :class:`~pyasn1.type.tagmap.TagMap` object mapping
            ASN.1 tags to ASN.1 objects contained within callee.
        )r   r   r9  fgetr  r  rl   s    r(   r9  zChoice.tagMapE  s0    
 ;;::??4((%%222r)   c                     | j                   t        j                  d      | j                  | j                      }|r!t	        |t
              r|j                  |      S |S )zReturn currently assigned component of the |ASN.1| object.

        Returns
        -------
        : :py:class:`~pyasn1.type.base.PyAsn1Item`
            a PyASN1 object
        r  )r  r   r   r  r+  r   r  r%   r  cs      r(   r  zChoice.getComponentO  sX     ###$:;;%%d&6&67AZ62~~i00r)   c                    | j                   t        j                  d      |r:| j                  | j                      }t	        |t
              r|j                  |      S | j                  j                  | j                         S )zReturn the name of currently assigned component of the |ASN.1| object.

        Returns
        -------
        : :py:class:`str`
            |ASN.1| component name
        r  )	r  r   r   r  r+  r   r  r  rj  r  s      r(   r  zChoice.getName`  sq     ###$:;;))$*:*:;a(99Y//%%778H8HIIr)   c                 z    | j                   y| j                  | j                      }|t        uxr |j                  S )a~  Indicate that |ASN.1| object represents ASN.1 value.

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

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

        Returns
        -------
        : :class:`bool`
            :obj:`False` if object represents just ASN.1 schema.
            :obj:`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).
        F)r  r  r   r!  rO  s     r(   r!  zChoice.isValueq  s?    8 #..t/?/?@W,G1G1GGr)   c                 :    d | _         t        j                  |       S r+   )r  r   r?  rl   s    r(   r?  zChoice.clear  s    yyr)   c                     | j                   S r+   )	minTagSetrl   s    r(   getMinTagSetzChoice.getMinTagSet  r  r)   r  ),r   r   r   r   r
   TagSetr   r   r  r  r   r   ValueSizeConstraintr   r   r   r   r  r   r   r   r   r   r   r  r   rg  r   r  r  r  r  r  r   r  r  r  r  r9  r  r  r!  r?  r  r   r)   r(   r   r   t  s$   +^ SZZ\F )I((*M
 5*44&
&&q!,K
 ]]_FK





+7E
=:AY<F" 3:t * 1815)-04*X - - 3 3"J"  H  HDr)   r   c                       e Zd ZdZ ej
                         Z ej                         Z	e
j                         Zed        Zy)r   a  Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`,
    its objects are immutable and duck-type :class:`bytes`.
    When used in Unicode context, |ASN.1| type assumes
    "|encoding|" serialisation.

    Keyword Args
    ------------
    value: :class:`unicode`, :class:`str`, :class:`bytes` or |ASN.1| object
        :class:`bytes`, alternatively :class:`str`
        representing character string to be serialised into octets (note
        `encoding` parameter) or |ASN.1| object.
        If `value` is not given, schema object will be created.

    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). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

    encoding: :py:class:`str`
        Unicode codec ID to encode/decode
        :class:`str` 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
    ------
    ~pyasn1.error.ValueConstraintError, ~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                     	 | j                   S # t        $ r_ t        j                  | j                  | it
        j                  j                  t
        j                  i|       | _         | j                   cY S w xY wr  )_tagMapAttributeErrorr   TagMapr   r   endOfOctetsrl   s    r(   r9  z
Any.tagMap  sa    

	 << 	 !==d#''9DL <<	 s    A%A65A6N)r   r   r   r   r
   r  r   r   r   r   r   r   r   r  r9  r   r)   r(   r   r     sL    @H SZZ\F
 5*446K ""$F   r)   r   )'r   r  pyasn1r   pyasn1.codec.berr   pyasn1.compatr   pyasn1.typer   r   r   r	   r
   r   r   r   __all__r"   r   r   rk   r   r   r   r   r   r  r   r   r  r   r   r   r   r   r   r   r   r   r)   r(   <module>r     sq    
    !  " !    
,,
)!c d!! c L=!g =!@3 ]## ]@S%$%% S%l1; 1hH1t** H1V~1$%% ~1BN4 NbB) B)NHT55 HT0' 0.0" 0.x	011 x	0t !  Fy3
 y3xgS gT	^ + ^ r)   