§
    ¤	Êj«	  ã                  óv   — d Z ddlmZ ddlZddlmZ 	 ddlmZ n# e$ r	 ddl	mZ Y nw xY w G d„ d¦  «        Z
dS )z<For internal use only. It provides a slice-like file reader.é    )ÚannotationsN)Úoverload)ÚLockc                  ó–   — e Zd ZdZdd„Zedd	„¦   «         Zedd„¦   «         Zdd„Zdd„Zd d„Zd!d„Z	 e
ed¦  «        rd"d„ZdS d"d„ZdS )#Ú
FileBufferzA slice-able file reader.ÚdatabaseÚstrÚreturnÚNonec                óî   — t          |d¦  «        | _        t          j        | j                             ¦   «         ¦  «        j        | _        t          t          d¦  «        st          ¦   «         | _	        dS dS )zCreate FileBuffer.ÚrbÚpreadN)
ÚopenÚ_handleÚosÚfstatÚfilenoÚst_sizeÚ_sizeÚhasattrr   Ú_lock)Úselfr   s     ú>C:\Projects\Muse2API\.venv\Lib\site-packages\maxminddb/file.pyÚ__init__zFileBuffer.__init__   s`   € å˜H dÑ+Ô+ˆŒÝ”X˜dœl×1Ò1Ñ3Ô3Ñ4Ô4Ô<ˆŒ
Ý•r˜7Ñ#Ô#ð 	 Ý™œˆDŒJˆJˆJð	 ð 	 ó    ÚindexÚintc                ó   — d S ©N© ©r   r   s     r   Ú__getitem__zFileBuffer.__getitem__   s   € Ø.1¨cr   ÚsliceÚbytesc                ó   — d S r   r    r!   s     r   r"   zFileBuffer.__getitem__   s   € Ø25°#r   úslice | intúbytes | intc                ó   — t          |t          ¦  «        r(|                      |j        |j        z
  |j        ¦  «        S t          |t
          ¦  «        r|                      d|¦  «        d         S d}t          |¦  «        ‚)zGet item by index.é   r   zInvalid argument type.)Ú
isinstancer#   Ú_readÚstopÚstartr   Ú	TypeError)r   r   Úmsgs      r   r"   zFileBuffer.__getitem__   sp   € å�e�UÑ#Ô#ð 	EØ—:’:˜eœj¨5¬;Ñ6¸¼ÑDÔDÐDÝ�e�SÑ!Ô!ð 	+Ø—:’:˜a Ñ'Ô'¨Ô*Ð*Ø&ˆÝ˜‰nŒnÐr   Úneedler-   c                ó„   — |                       | j        |z
  dz
  |¦  «                             |¦  «        }|dk    r|S ||z   S )zReverse find needle from start.r)   éÿÿÿÿ)r+   r   Úrfind)r   r0   r-   Úposs       r   r3   zFileBuffer.rfind'   sG   € à�jŠj˜œ eÑ+¨aÑ/°Ñ7Ô7×=Ò=¸fÑEÔEˆØ�"Š9ˆ9ØˆJØ�s‰{Ðr   c                ó   — | j         S )zSize of file.)r   ©r   s    r   ÚsizezFileBuffer.size.   s
   € àŒzÐr   c                ó8   — | j                              ¦   «          dS )zClose file.N)r   Úcloser6   s    r   r9   zFileBuffer.close2   s   € àŒ×ÒÑÔÐÐÐr   r   Ú
buffersizeÚoffsetc                ó\   — t          j        | j                             ¦   «         ||¦  «        S )zRead that uses pread.)r   r   r   r   ©r   r:   r;   s      r   r+   zFileBuffer._read8   s$   € å”8˜DœL×/Ò/Ñ1Ô1°:¸vÑFÔFÐFr   c                ó¬   — | j         5  | j                             |¦  «         | j                             |¦  «        cddd¦  «         S # 1 swxY w Y   dS )a°  Read with a lock.

            This lock is necessary as after a fork, the different processes
            will share the same file table entry, even if we dup the fd, and
            as such the same offsets. There does not appear to be a way to
            duplicate the file table entry and we cannot re-open based on the
            original path as that file may have replaced with another or
            unlinked.
            N)r   r   ÚseekÚreadr=   s      r   r+   zFileBuffer._read>   s™   € ð ”ð 5ð 5Ø”×!Ò! &Ñ)Ô)Ð)Ø”|×(Ò(¨Ñ4Ô4ð5ð 5ð 5ð 5ñ 5ô 5ð 5ð 5ð 5ð 5ð 5ð 5øøøð 5ð 5ð 5ð 5ð 5ð 5s   ˆ4A	Á	AÁAN)r   r	   r
   r   )r   r   r
   r   )r   r#   r
   r$   )r   r&   r
   r'   )r0   r$   r-   r   r
   r   )r
   r   )r
   r   )r:   r   r;   r   r
   r$   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r"   r3   r7   r9   r   r   r+   r    r   r   r   r      sú   € € € € € Ø#Ð#ð ð  ð  ð  ð Ø1Ð1Ð1ñ „XØ1àØ5Ð5Ð5ñ „XØ5ðð ð ð ðð ð ð ðð ð ð ðð ð ð ð €wˆr�7ÑÔð 5ð	Gð 	Gð 	Gð 	Gð 	Gð 	Gð	5ð 	5ð 	5ð 	5ð 	5ð 	5r   r   )rD   Ú
__future__r   r   Útypingr   Úmultiprocessingr   ÚImportErrorÚ	threadingr   r    r   r   ú<module>rJ      s·   ðØ BÐ Bà "Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø Ð Ð Ð Ð Ð ðØ$Ð$Ð$Ð$Ð$Ð$Ð$øØð ð ð ØÐÐÐÐÐÐÐðøøøð<5ð <5ð <5ð <5ð <5ñ <5ô <5ð <5ð <5ð <5s   ” ›)¨)