ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib64/python3.11/site-packages/smmap/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/smmap/__pycache__/buf.cpython-311.pyc

�

�܋f���2�dZddlZdgZGd�d��ZdS)zCModule with a simple buffer implementation using the memory manager�N�SlidingWindowMapBufferc�z�eZdZdZdZddejdfd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ddejdfd�Zd
�Zd�ZdS)raA buffer like object which allows direct byte-wise object and slicing into
    memory of a mapped file. The mapping is controlled by the provided cursor.

    The buffer is relative, that is if you map an offset, index 0 will map to the
    first byte at the offset you used during initialization or begin_access

    **Note:** Although this type effectively hides the fact that there are mapped windows
    underneath, it can unfortunately not be used in any non-pure python method which
    needs a buffer or string)�_c�_sizeNrc�j�||_|r'|�||||��std���dSdS)aeInitalize the instance to operate on the given cursor.
        :param cursor: if not None, the associated cursor to the file you want to access
            If None, you have call begin_access before using the buffer and provide a cursor
        :param offset: absolute offset in bytes
        :param size: the total size of the mapping. Defaults to the maximum possible size
            From that point on, the __len__ of the buffer will be the given size or the file size.
            If the size is larger than the mappable area, you can only access the actually available
            area, although the length of the buffer is reported to be your given size.
            Hence it is in your own interest to provide a proper size !
        :param flags: Additional flags to be passed to os.open
        :raise ValueError: if the buffer could not achieve a valid statezJFailed to allocate the buffer - probably the given offset is out of boundsN)r�begin_access�
ValueError)�self�cursor�offset�size�flagss     �Z/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/smmap/buf.py�__init__zSlidingWindowMapBuffer.__init__sW������	k�$�+�+�F�F�D�%�H�H�	k��i�j�j�j�	k�	k�	k�	k�c�.�|���dS�N��
end_access�r
s r�__del__zSlidingWindowMapBuffer.__del__(����������rc��|Sr�rs r�	__enter__z SlidingWindowMapBuffer.__enter__+s���rc�.�|���dSrr)r
�exc_type�	exc_value�	tracebacks    r�__exit__zSlidingWindowMapBuffer.__exit__.rrc��|jSr)rrs r�__len__zSlidingWindowMapBuffer.__len__1s
���z�rc��t|t��r)|�|jpd|jp|j��S|j}|���sJ�|dkr
|j|z}|�|��s|�	|d��|�
��||���z
S)Nr�)�
isinstance�slice�__getslice__�start�stoprr�is_valid�includes_ofs�
use_region�buffer�	ofs_begin)r
�i�cs   r�__getitem__z"SlidingWindowMapBuffer.__getitem__4s����a����	I��$�$�Q�W�\��1�6�3G�T�Z�H�H�H��G���z�z�|�|���|��q�5�5��
�Q��A��~�~�a� � �	�
�L�L��A�����x�x�z�z�!�a�k�k�m�m�+�,�,rc�4�|j}|���sJ�|dkr
|j|z}|tjkr|j}|dkr
|j|z}|���|krN||���kr6|���}|���||z
||z
�S||z
}|}t��}|r�|�	||��|���sJ�|���d|�}|t|��z
}|t|��z}t|d��r|���}|�
|��|��t���|��S)Nr�tobytes)rr*r�sys�maxsizer.�ofs_endr-�listr,�len�hasattrr3�append�bytes�join)	r
r/�jr0�b�l�ofs�md�ds	         rr'z#SlidingWindowMapBuffer.__getslice__@sv���G���z�z�|�|���|��q�5�5��
�Q��A�������
�A��q�5�5��
�Q��A�
�K�K�M�M�Q���Q������_�_����
�
�A��8�8�:�:�a�!�e�A��E�k�*�*��A��A��C����B��

����S�!�$�$�$��z�z�|�|�#�#�|��H�H�J�J�r��r�N���s�1�v�v�
���S��V�V����1�i�(�(�$��	�	���A��	�	�!�����

��7�7�<�<��#�#�#rc�<�|r||_|j��|j���rr|j�|||�����}|r@||j���kr|j���|z
}||_|SdS)aUCall this before the first use of this instance. The method was already
        called by the constructor in case sufficient information was provided.

        For more information no the parameters, see the __init__ method
        :param path: if cursor is None the existing one will be used.
        :return: True if the buffer can be usedNF)r�
is_associatedr,r*�	file_sizer)r
rrr
r�ress      rrz#SlidingWindowMapBuffer.begin_accessds����	��D�G��7��4�7�#8�#8�#:�#:���'�$�$�V�T�5�9�9�B�B�D�D�C��
"�
�$�'�+�+�-�-�-�-��7�,�,�.�.��7�D�!��
��J��urc�X�d|_|j�|j���dSdS)aCall this method once you are done using the instance. It is automatically
        called on destruction, and should be called just in time to allow system
        resources to be freed.

        Once you called end_access, you must call begin access before reusing this instance!rN)rr�unuse_regionrs rrz!SlidingWindowMapBuffer.end_access�s5����
��7���G� � �"�"�"�"�"��rc��|jS)zC:return: the currently set cursor which provides access to the data)rrs rrzSlidingWindowMapBuffer.cursor�s	���w�r)�__name__�
__module__�__qualname__�__doc__�	__slots__r4r5rrrr r"r1r'rrrrrrrrs������� � ��I�
#�1�3�;�a�k�k�k�k�"������������
-�
-�
-� $� $� $�H#'�q�s�{�!�����8#�#�#�����r)rMr4�__all__rrrr�<module>rPsX��I�I�
�
�
�
�#�
$��F�F�F�F�F�F�F�F�F�Fr

Zerion Mini Shell 1.0