
    ,h                     8    d dl mZ ddlmZ dZdZ G d d      Zy)	    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.
    c                 z    t         t        |           || _        |t        k(  rt        nt
        | _        || _        y N)superr
   __init___streamLITTLE_ENDIAN
BIG_ENDIAN_byte_order_base_offset)selfstream
byte_orderbase_offset	__class__s       T/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/docx/image/helpers.pyr   zStreamReader.__init__   s0    lD*,,6-,G=Z'    c                 8    | j                   j                  |      S )zAllow pass-through read() call.)r   read)r   counts     r   r   zStreamReader.read   s    ||  ''r   c                 ,    d}| j                  |||      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0r   c                 T    | j                   t        u rdnd}| j                  |||      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#   s+     &&-7dT~~c400r   c                 T    | j                   t        u rdnd}| j                  |||      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.   s+     ''=8ee~~c400r   c                 d    d } ||      }| j                  |||      }|j                  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   s;    	# J'!!&$7ll7+r   c                 ^    | j                   |z   |z   }| j                  j                  |       y r   )r   r   seek)r   r"   r#   locations       r   r7   zStreamReader.seekA   s)    $$t+f4(#r   c                 6    | j                   j                         S )zAllow pass-through tell() call.)r   tell)r   s    r   r:   zStreamReader.tellE   s    ||  ""r   c                     | j                  ||       | j                  j                  |      }t        |      |k  rt        |S r   )r7   r   r   lenr   )r   
byte_countr"   r#   bytes_s        r   _read_byteszStreamReader._read_bytesI   s;    		$"":.v;#**r   c                 >    t        |      }| j                  |||      S r   )r   r0   )r   r$   r"   r#   r2   s        r   r    zStreamReader._read_intP   s       v66r   c                 d    | j                  |j                  ||      }|j                  |      d   S )Nr   )r?   sizeunpack)r   r2   r"   r#   r>   s        r   r0   zStreamReader._unpack_itemT   s.    !!&++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$#7(r   r
   N)r2   r   
exceptionsr   r   r   r
    r   r   <module>rK      s!     0
M( M(r   