
    4)di                    n    d dl m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
mZ d dlmZ d dlmZ ddZdS )    )annotationsN)	BitStream)tokenparser)CreationError)UnionList)BitStore)bitstore_from_tokenfmtUnion[str, List[str]]returnr   c           
     (   g }t          | t                    r| g} 	 | D ]V}t          |t          t	          |                                                              \  }}|                    |           Wn # t          $ r}t          |j	         d}~ww xY wt          |          }g }		 |D ].\  }
}}|                    ||          }|                    ||          }|
|v r2|0|.|	                    t          ||
                   j                   i|t          |          }||
dk    rt!          |          }|
dk    rst"          j                            |          }|6|t)          |          k    r#t          d| dt)          |           d          |	                    |j                   
|	                    t+          |
||                     0n.# t,          $ r! t          dt)          |           d          w xY w	 t!          |           nZ# t,          $ rM t                      }t"          j        j        r|	                                 |	D ]}|xj        |z  c_        |cY S w xY wt          d	t)          |           d
          )at  Pack the values according to the format string and return a new BitStream.

    fmt -- A single string or a list of strings with comma separated tokens
           describing how to create the BitStream.
    values -- Zero or more values to pack according to the format.
    kwargs -- A dictionary or keyword-value pairs - the keywords used in the
              format string will be replaced with their given value.

    Token examples: 'int:12'    : 12 bits as a signed integer
                    'uint:8'    : 8 bits as an unsigned integer
                    'float:64'  : 8 bytes as a big-endian float
                    'intbe:16'  : 2 bytes as a big-endian signed integer
                    'uintbe:16' : 2 bytes as a big-endian unsigned integer
                    'intle:32'  : 4 bytes as a little-endian signed integer
                    'uintle:32' : 4 bytes as a little-endian unsigned integer
                    'floatle:64': 8 bytes as a little-endian float
                    'intne:24'  : 3 bytes as a native-endian signed integer
                    'uintne:24' : 3 bytes as a native-endian unsigned integer
                    'floatne:32': 4 bytes as a native-endian float
                    'hex:80'    : 80 bits as a hex string
                    'oct:9'     : 9 bits as an octal string
                    'bin:1'     : single bit binary string
                    'ue' / 'uie': next bits as unsigned exp-Golomb code
                    'se' / 'sie': next bits as signed exp-Golomb code
                    'bits:5'    : 5 bits as a bitstring object
                    'bytes:10'  : 10 bytes as a bytes object
                    'bool'      : 1 bit as a bool
                    'pad:3'     : 3 zero bits as padding

    >>> s = pack('uint:12, bits', 100, '0xffe')
    >>> t = pack(['bits', 'bin:3'], s, '111')
    >>> u = pack('uint:8=a, uint:8=b, uint:55=a', a=6, b=44)

    NpadbitszToken with length z packed with value of length .z?Not enough parameters present to pack according to the format. z values are needed.zBToo many parameters present to pack according to the format. Only z values were expected.)
isinstancestrr   tuplesortedkeysextend
ValueErrorr   argsitergetappendr   	_bitstoreintnext	bitstringr   Bitslenr
   StopIterationoptionslsb0reverse)r   valueskwargstokensf_item_tknse
value_iterbslnamelengthvaluesbs                  X/var/www/menimich/repos/protonApp/venv/lib/python3.11/site-packages/bitstring/methods.pypackr6      s   F F#s e% 	  	 F!&%v{{}}0E0E*F*FGGGAtMM$	   % % %QV$$%fJCI#) 	A 	AD&%JJue,,EZZ//Fv~~&.U]

9VD\22<===!V}Z((v~~!++E22%&CJJ*>*>'(oV(o(obefkblbl(o(o(oppp

5?+++JJ*4??@@@@)	A*  I I I H'*6{{H H H I I 	II	Z   KK! 	KKMMM 	 	AKK1KKK   A]`ag]h]h  A  A  A  B  B  Bs8   AA6 6
B BB(D2G +H
H AI10I1)r   r   r   r   )
__future__r   r    bitstring.bitstreamr   bitstring.utilsr   bitstring.exceptionsr   typingr   r   bitstring.bitstorer	   bitstring.bitstore_helpersr
   r6        r5   <module>r@      s    " " " " " "     ) ) ) ) ) ) ' ' ' ' ' ' . . . . . .         ' ' ' ' ' ' : : : : : :SB SB SB SB SB SBr?   