Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/maxminddb/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/maxminddb/__pycache__/file.cpython-35.pyc



�jvX��@sedZddlZyddlmZWn"ek
rJddlmZYnXGdd�de�ZdS)z<For internal use only. It provides a slice-like file reader.�N)�Lockc@s|eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	e
d�rld
d�Zndd�ZdS)�
FileBufferzA slice-able file readercCsOt|d�|_tj|jj��j|_ttd�sKt�|_	dS)N�rb�pread)
�open�_handle�os�fstat�fileno�st_size�_size�hasattrr�_lock)�selfZdatabase�r�A/opt/alt/python35/lib64/python3.5/site-packages/maxminddb/file.py�__init__szFileBuffer.__init__cCs[t|t�r,|j|j|j|j�St|t�rK|jd|�Std��dS)N�zInvalid argument type.)�
isinstance�slice�_read�stop�start�int�	TypeError)r�keyrrr�__getitem__s
zFileBuffer.__getitem__cCs>|j|j|d|�j|�}|dkr6|S||S)zReverse find needle from startr���)rr�rfind)rZneedler�posrrrrs&zFileBuffer.rfindcCs|jS)zSize of file)r)rrrr�size$szFileBuffer.sizecCs|jj�dS)z
Close fileN)r�close)rrrrr!(szFileBuffer.closercCstj|jj�||�S)zread that uses pread)rrrr
)r�
buffersize�offsetrrrr.szFileBuffer._readc	Cs5|j�%|jj|�|jj|�SWdQRXdS)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)rr�seek�read)rr"r#rrrr5s

N)�__name__�
__module__�__qualname__�__doc__rrrr r!r
rrrrrrrsr)r)r�multiprocessingr�ImportError�	threading�objectrrrrr�<module>s