
    hi                     @    d dl mZ ddlmZ dZdZ G d d          ZdS )	    Struct   )UnexpectedEndOfFileError><c                   j     e Zd ZdZd fd	Zd ZddZddZddZddZ	dd	Z
d
 Zd Zd Zd Z xZS )StreamReaderzWraps 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.
    r   c                     t          t          |                                            || _        |t          k    rt          nt
          | _        || _        d S N)superr
   __init___streamLITTLE_ENDIAN
BIG_ENDIAN_byte_order_base_offset)selfstream
byte_orderbase_offset	__class__s       j/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/docx/image/helpers.pyr   zStreamReader.__init__   sJ    lD!!**,,,,6-,G,G==Z'    c                 6    | j                             |          S )zAllow pass-through read() call.)r   read)r   counts     r   r   zStreamReader.read   s    |  '''r   c                 4    d}|                      |||          S )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_bytezStreamReader.read_byte   s     ~~c4000r   c                 T    | j         t          u rdnd}|                     |||          S )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_longzStreamReader.read_long#   s0     &-77ddT~~c4000r   c                 T    | j         t          u rdnd}|                     |||          S )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_shortzStreamReader.read_short.   s0     '=88eee~~c4000r   c                 z    d } ||          }|                      |||          }|                    d          }|S )zReturn a string containing the `char_count` bytes at the file position
        determined by self._base_offset + `base` + `offset`.c                 *    d| z  }t          |          S )Nz%dsr   )
char_countformat_s     r   
str_structz)StreamReader.read_str.<locals>.str_struct8   s    j(G'??"r   zUTF-8)_unpack_itemdecode)r   r-   r"   r#   r/   structcharsunicode_strs           r   read_strzStreamReader.read_str4   sP    	# 	# 	# J''!!&$77ll7++r   c                 T    | j         |z   |z   }| j                            |           d S r   )r   r   seek)r   r"   r#   locations       r   r7   zStreamReader.seekA   s0    $t+f4(#####r   c                 4    | j                                         S )zAllow pass-through tell() call.)r   tell)r   s    r   r:   zStreamReader.tellE   s    |  """r   c                     |                      ||           | j                            |          }t          |          |k     rt          |S r   )r7   r   r   lenr   )r   
byte_countr"   r#   bytes_s        r   _read_byteszStreamReader._read_bytesI   sG    		$"":..v;;##**r   c                 N    t          |          }|                     |||          S r   )r   r0   )r   r$   r"   r#   r2   s        r   r    zStreamReader._read_intP   s%      v666r   c                 p    |                      |j        ||          }|                    |          d         S )Nr   )r?   sizeunpack)r   r2   r"   r#   r>   s        r   r0   zStreamReader._unpack_itemT   s2    !!&+tV<<}}V$$Q''r   )r   )__name__
__module____qualname____doc__r   r   r%   r(   r*   r5   r7   r:   r?   r    r0   __classcell__)r   s   @r   r
   r
   	   s         ( ( ( ( ( (( ( (1 1 1 1	1 	1 	1 	11 1 1 1   $ $ $ $# # #  7 7 7( ( ( ( ( ( (r   r
   N)r2   r   
exceptionsr   r   r   r
    r   r   <module>rK      so          0 0 0 0 0 0
M( M( M( M( M( M( M( M( M( M(r   