
    h                     8    S SK Jr  SSKJr  SrSr " S S5      rg)	    Struct   )UnexpectedEndOfFileError><c                      ^  \ rS rSrSrSU 4S jjrS rSS jrSS jrSS jr	SS jr
SS	 jrS
 rS rS rS rSrU =r$ )StreamReader	   zWraps a file-like object to provide access to structured data from a binary file.

Byte-order is configurable. `base_offset` is added to any base value provided to
calculate actual location for reads.
c                 x   > [         [        U ]  5         Xl        U[        :X  a  [        O[
        U l        X0l        g N)superr
   __init___streamLITTLE_ENDIAN
BIG_ENDIAN_byte_order_base_offset)selfstream
byte_orderbase_offset	__class__s       D/var/www/html/env/lib/python3.13/site-packages/docx/image/helpers.pyr   StreamReader.__init__   s,    lD*,,6-,G=Z'    c                 8    U R                   R                  U5      $ )zAllow pass-through read() call.)r   read)r   counts     r   r   StreamReader.read   s    ||  ''r   c                 *    SnU R                  X1U5      $ )zReturn the int value of the byte at the file position defined by
self._base_offset + `base` + `offset`.

If `base` is None, the byte is read from the current position in the stream.
B)	_read_intr   baseoffsetfmts       r   	read_byteStreamReader.read_byte   s     ~~c00r   c                 T    U R                   [        L a  SOSnU R                  X1U5      $ )a  Return the int value of the four bytes at the file position defined by
self._base_offset + `base` + `offset`.

If `base` is None, the long is read from the current position in the stream. The
endian setting of this instance is used to interpret the byte layout of the
long.
z<Lz>Lr   r   r#   r$   s       r   	read_longStreamReader.read_long#   s)     &&-7dT~~c00r   c                 T    U R                   [        L a  SOSnU R                  X1U5      $ )zReturn the int value of the two bytes at the file position determined by
`base` and `offset`, similarly to ``read_long()`` above.s   <Hs   >Hr+   r$   s       r   
read_shortStreamReader.read_short.   s)     ''=8ee~~c00r   c                 b    S nU" U5      nU R                  XRU5      nUR                  S5      nU$ )z{Return a string containing the `char_count` bytes at the file position
determined by self._base_offset + `base` + `offset`.c                 "    SU -  n[        U5      $ )Nz%dsr   )
char_countformat_s     r   
str_struct)StreamReader.read_str.<locals>.str_struct8   s    j(G'?"r   zUTF-8)_unpack_itemdecode)r   r3   r%   r&   r5   structcharsunicode_strs           r   read_strStreamReader.read_str4   s9    	# J'!!&7ll7+r   c                 ^    U R                   U-   U-   nU R                  R                  U5        g r   )r   r   seek)r   r%   r&   locations       r   r?   StreamReader.seekA   s)    $$t+f4(#r   c                 6    U R                   R                  5       $ )zAllow pass-through tell() call.)r   tell)r   s    r   rC   StreamReader.tellE   s    ||  ""r   c                     U R                  X#5        U R                  R                  U5      n[        U5      U:  a  [        eU$ r   )r?   r   r   lenr   )r   
byte_countr%   r&   bytes_s        r   _read_bytesStreamReader._read_bytesI   s9    		$"":.v;#**r   c                 <    [        U5      nU R                  XBU5      $ r   )r   r7   )r   r'   r%   r&   r9   s        r   r#   StreamReader._read_intP   s      v66r   c                 b    U R                  UR                  X#5      nUR                  U5      S   $ )Nr   )rI   sizeunpack)r   r9   r%   r&   rH   s        r   r7   StreamReader._unpack_itemT   s,    !!&++t<}}V$Q''r   )r   r   r   )r   )__name__
__module____qualname____firstlineno____doc__r   r   r(   r,   r/   r<   r?   rC   rI   r#   r7   __static_attributes____classcell__)r   s   @r   r
   r
   	   sD    ((1	11$#7( (r   r
   N)r9   r   
exceptionsr   r   r   r
    r   r   <module>rZ      s!     0
M( M(r   