OwlCyberSecurity - MANAGER
Edit File: util.cpython-311.pyc
� ������h0���������������������������d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlmZ�d�dlm Z m Z mZ��e ��������������Zd�dl Z �d�dlmZ�n!#�e$�r�d�dlmZmZ��e��������������Zdd�ZY�nw�xY�we�j��������Ze�j��������Zej��������Zej��������j��������Zej��������Zej��������Zej��������j��������Zej��������j��������Zej ��������Z ej��������j!��������Z!ej��������j"��������Z"ej��������j#��������Z#ej$��������Z$ej%��������Z%ej&��������Z&ej'��������Z'd��Z(d��Z)d�d l*m+Z+m,Z,��G�d ��d������������Z-d��Z.dd�Z/d��Z0dd�Z1dd�Z2dd�Z3d��Z4d��Z5�G�d��d������������Z6�G�d��d������������Z7dS�)�����N)�BytesIO)�StaticWindowMapManager�SlidingWindowMapManager�SlidingWindowMapBuffer)�unpack_from)�unpack�calcsizec����������������������� �t�����������|����������}n)#�t����������$�r�t����������|�������������}|t�����������|�<���Y�nw�xY�wt����������|�||||z�������������������������S��N)�__calcsize_cache�KeyErrorr ���r���)�fmt�data�offset�sizes��� �[/builddir/build/BUILD/cloudlinux-venv-1.0.8/venv/lib/python3.11/site-packages/gitdb/util.pyr���r���!���sj������ )�#�C�(�D�D���� )�� )�� )��C�=�=�D�$(��S�!�!�!� )������c�4���� � 5�6�7�7�7s���� ��#6�6c������������������������t�����������j��������dk����rHt����������d������������D�]0} ��|�|i�|��c�S�#�t����������$�r�t ����������j��������d�������������Y��-w�xY�w�|�|i�|��S��|�|i�|��S�)N�win32� ���g�������?)�sys�platform�range� Exception�time�sleep)�func�args�kwargs�_s��� r����_retryr ���D���s���������|�w����r���� �� �A� ��t�T�,�V�,�,�,�,�,���� �� �� �� �3������ �����t�T�$�V�$�$�$��t�T�$�V�$�$�$s����-�A� Ac�������������������6�����t����������t����������j��������g|��R�i�|��S�r���)r ����os�remove)r���r���s��� r���r#���r#���R���s"�������"�)�-�d�-�-�-�f�-�-�-�����)�NULL_BIN_SHA�NULL_HEX_SHAc��������������������6�����e�Zd�ZdZdZd d�Zd��Zd��Zd��Zd��Z d S�)�_RandomAccessBytesIOz�Wrapper to provide required functionality in case memory maps cannot or may not be used. This is only really required in python 2.4�_sio��c������������������.�����t����������|������������|�_��������d�S�r���)r���r)���)�self�bufs��� r����__init__z_RandomAccessBytesIO.__init__g���s�������C�L�L�� � � r$���c������������������,�����t����������|�j��������|������������S�r���)�getattrr)����r,����attrs��� r����__getattr__z _RandomAccessBytesIO.__getattr__j���s�������t�y�$�'�'�'r$���c������������������D�����t����������|������������������������������������������������S�r���)�len�getvalue�r,���s��� r����__len__z_RandomAccessBytesIO.__len__m���s�������4�=�=�?�?�#�#�#r$���c������������������6�����|�������������������������������������|���������S�r����r6���)r,����is��� r����__getitem__z _RandomAccessBytesIO.__getitem__p���s�������}�}���q�!�!r$���c������������������:�����|�������������������������������������||����������S�r���r:���)r,����start�ends��� r����__getslice__z!_RandomAccessBytesIO.__getslice__s���s�������}�}���u�S�y�)�)r$���N)r*���) �__name__� __module__�__qualname__�__doc__� __slots__r.���r3���r8���r<���r@�����r$���r���r(���r(���a���ss��������������?��?��I�!��!��!��!�(��(��(�$��$��$�"��"��"�*��*��*��*��*r$���r(���c������������������F����� �t����������|�������������S�#�t����������$�r�|�cY�S�w�xY�w)z� Return the integer representation of the byte string. This supports Python 3 byte arrays as well as standard strings. )�ord� TypeError)�bs��� r����byte_ordrK���w���s6������ ��1�v�v� ����������������s������ � r$���c����������������������� �t����������j��������|�������������S�#�t����������$�r�ddl}|���������������������|�������������}|cY�S�w�xY�w)z`A python2.4 workaround for the sha/hashlib module fiasco **Note** From the dulwich project r���N)�hashlib�sha1� NameError�sha)�sourcerP���rN���s��� r����make_sharR�������sS��������|�F�#�#�#���������� � � ��w�w�v�����������s������%>�>c�����������������������|�dk����rt����������d������������S� �t����������j��������d|�������������S�#�t����������$�r�t����������d|�z��������������cY�S�w�xY�w)zB:return: a file-protocol accessible memory block of the given sizer���r$�����������)r(����mmap�OSError)r���s��� r����allocate_memoryrX�������se�������q�y�y�#�C�(�(�(�2��y��T�"�"�"����2��2��2� �$�E�D�L�1�1�1�1�1�2���s����,��A� AFTc������������������|���� �|rj �t����������j���������|�dt�����������j���������������������S�#�t����������$�r;�t����������j���������|�t����������j��������|�������������j��������t�����������j���������������������cY�S�w�xY�wn#�t����������$�r�Y�nw�xY�wt����������j��������|�t����������j��������|�������������j��������������������}|rt����������|������������S�|S�)a���:return: read-only contents of the file represented by the file descriptor fd :param fd: file descriptor opened for reading :param stream: if False, random access is provided, otherwise the stream interface is provided. :param allow_mmap: if True, its allowed to map the contents into memory, which allows large files to be handled and accessed efficiently. The file-descriptor will change its position if this is Falser���)�access)rV����ACCESS_READrW���r"����fstat�st_size�readr(���)�fd�stream� allow_mmap�contentss��� r����file_contents_rorc�������s������� ��� T� T��y��Q�t�/?�@�@�@�@���� T�� T�� T��y��R�X�b�\�\�%9�$�BR�S�S�S�S�S�S� T���� T����� �� �� ��� ���� ��w�r�2�8�B�<�<�/�0�0�H� ��.�#�H�-�-�-��Os-����A/�� &��AA+�(A/��*A+�+A/��/ A<�;A<c����������� �������������t����������j��������|�t�����������j��������t����������t�����������dd������������z��|z��������������} �t ����������|||������������t����������|�������������S�#�t����������|�������������w�xY�w)a<��Get the file contents at filepath as fast as possible :return: random access compatible memory of the given filepath :param stream: see ``file_contents_ro`` :param allow_mmap: see ``file_contents_ro`` :param flags: additional flags to pass to os.open :raise OSError: If the file could not be opened **Note** for now we don't try to use O_NOATIME directly as the right value needs to be shared per database in fact. It only makes a real difference for loose object databases anyway, and they use it with the help of the ``flags`` parameter�O_BINARYr���)r"����open�O_RDONLYr0���rc����close)�filepathr`���ra����flagsr_���s��� r����file_contents_ro_filepathrk�������s^������� ���2�;���Z��)C�)C�C�e�K� L� L�B����F�J�7�7� �b� � � � ���b� � � � ���s����A��A,c������������������T�����t����������t�������������������������������|�������������|�������������S�)z� :return: a buffer compatible object which uses our mapped memory manager internally ready to read the whole given filepath)rj���)r����mman�make_cursor)ri���rj���s��� r����sliding_ro_bufferro�������s%�������"�$�"2�"2�8�"<�"<�E�J�J�J�Jr$���c������������������J�����t����������|�������������dk����r|�S�t����������|�������������S�)z!:return: hexified version of sha�(���)r5���� bin_to_hex�rP���s��� r���� to_hex_shart�������s"������ �3�x�x�2�~�~�� ��c�?�?�r$���c������������������J�����t����������|�������������dk����r|�S�t����������|�������������S�)N����)r5���� hex_to_binrs���s��� r���� to_bin_sharx�������s"������ �3�x�x�2�~�~�� ��c�?�?�r$���c��������������������2�����e�Zd�ZdZ�e��������������Zd��Zd��ZdS�)� LazyMixina?�� Base class providing an interface to lazily retrieve attribute values upon first access. If slots are used, memory will only be reserved once the attribute is actually accessed and retrieved the first time. All future accesses will return the cached value as stored in the Instance's dict or slot. c������������������b�����|�����������������������|�������������t�������������������������������|�|������������S�)z� Whenever an attribute is requested that we do not know, we allow it to be created and set. Next time the same attribute is requested, it is simply returned from our dict/slots. )�_set_cache_�object�__getattribute__r1���s��� r���r3���zLazyMixin.__getattr__����s.������ � ��������&�&�t�T�2�2�2r$���c�����������������������dS�)a��� This method should be overridden in the derived class. It should check whether the attribute named by attr can be created and cached. Do nothing if you do not know the attribute or call your subclass The derived class may create as many additional attributes as it deems necessary in case a git command returns more information than represented in the single attribute.NrF���r1���s��� r���r|���zLazyMixin._set_cache_��s ������� �r$���N)rA���rB���rC���rD����tuplerE���r3���r|���rF���r$���r���rz���rz�������sI����������������������I�3��3��3� �� �� �� �� r$���rz���c��������������������D�����e�Zd�ZdZdZd��Zd��Zd��Zd d�Zd��Z d ��Z dd�ZdS�)�LockedFDa�� This class facilitates a safe read and write operation to a file on disk. If we write to 'file', we obtain a lock file at 'file.lock' and write to that instead. If we succeed, the lock file will be renamed to overwrite the original file. When reading, we obtain a lock file, but to prevent other writers from succeeding while we are reading the file. This type handles error correctly in that it will assure a consistent state on destruction. **note** with this setup, parallel reading is not possible�� _filepath�_fd�_writec������������������0�����||�_���������d|�_��������d|�_��������dS�)z.Initialize an instance with the givne filepathNr����)r,���ri���s��� r���r.���zLockedFD.__init__��s������!����������r$���c������������������@�����|�j����������|�������������������������������������d�S�d�S�r���)r�����rollbackr7���s��� r����__del__zLockedFD.__del__$��s#�������8���M�M�O�O�O�O�O�� �r$���c�����������������������d|�j���������z��S�)Nz%s.lock)r����r7���s��� r���� _lockfilepathzLockedFD._lockfilepath)��s�������4�>�)�)r$���Fc�����������������������|�j����������t����������d|�j��������z���������������||�_���������t����������t����������dd������������}t����������j��������t����������j��������z��t����������j��������z��|z��} �t ����������j��������|������������������������������������|t����������dd������������������������}|st ����������j ��������|�������������n||�_��������n7#�t����������$�r*}t����������d|������������������������������������z��������������|�d}~ww�xY�w|�j���������U �t ����������j��������|�j ��������t����������j��������|z��������������|�_��������n'#��t����������|���������������������������������������������������xY�w|rddlm}��||�j��������������������S�|�j��������S�) a��� Open the file descriptor for reading or writing, both in binary mode. :param write: if True, the file descriptor will be opened for writing. Other wise it will be opened read-only. :param stream: if True, the file descriptor will be wrapped into a simple stream object which supports only reading or writing :return: fd to read from or write to. It is still maintained by this instance and must not be closed directly :raise IOError: if the lock could not be retrieved :raise OSError: If the actual file could not be opened for reading **note** must only be called onceNzCalled %s multiple timesre���r����600����z Lock at %r could not be obtained)�FDStream)r�����AssertionErrorrf���r0���r"����O_WRONLY�O_CREAT�O_EXCLr�����intrh���r����rW���r����rg���r#����gitdb.streamr����)r,����writer`����binary�lockmoder_����er����s��� r���rf���z LockedFD.open,��sp�������;�"� �!;�d�i�!G�H�H�H�������Z��+�+���;���+�b�i�7�&�@�� \����+�+�-�-�x��U�A���G�G�B��� ��������������� \�� \�� \��<�t�?Q�?Q�?S�?S�S�T�T�Z[�[����� \���� ��8�� ��7�4�>�2�;��3G�H�H����� ��t�)�)�+�+�,�,�,�������� �-�-�-�-�-�-��8�D�H�%�%�%��8�Os%����&AB;��; C/�%C*�*C/�:,D'��'$Ec������������������2�����|�����������������������d��������������dS�)z�When done writing, call this function to commit your changes into the actual file. The file descriptor will be closed, and the lockfile handled. **Note** can be called multiple timesT�� successfulN��_end_writingr7���s��� r����commitzLockedFD.commita��s!������� ���T��*�*�*�*�*r$���c������������������2�����|�����������������������d��������������dS�)z�Abort your operation without any changes. The file descriptor will be closed, and the lock released. **Note** can be called multiple timesFr����Nr����r7���s��� r���r����zLockedFD.rollbacki��s!������ � ���U��+�+�+�+�+r$���Tc�����������������������|�j����������t����������d�������������|�j���������dS�t����������j��������|�j���������������������d|�_��������|������������������������������������}|�j���������ry|rwt����������j��������dk����r(t����������|�j ��������������������rt����������|�j ���������������������t����������j��������||�j ���������������������t����������|�j ��������t����������dd�������������������������dS�t����������|�������������dS�)z,Handle the lock according to the write mode Nz-Cannot end operation if it wasn't started yetr����644r����)r����r����r����r"���rh���r����r���r����isfiler����r#����rename�chmodr����)r,���r�����lockfiles��� r���r����zLockedFD._end_writingp��s��������;�� �!P�Q�Q�Q��8���F� �����������%�%�'�'���;�� �:�� ��|�w�&�&��$�.�)�)��+��4�>�*�*�*�� �I�h���/�/�/� � �$�.�#�e�Q�-�-�0�0�0�0�0�� �8�����r$���N)FF)T)rA���rB���rC���rD���rE���r.���r����r����rf���r����r����r����rF���r$���r���r����r���� ��s���������������B��B��/�I����������� *��*��*�2��2��2��2�j+��+��+�,��,��,�����������r$���r����)r���)r$���)FT)FTr���)8�binasciir"���rV���r���r����errno�ior����smmapr���r���r���rm���rM����structr����ImportErrorr���r ����dictr����a2b_hexrw����b2a_hexrr����ENOENT�path�exists�mkdirr�����isdirr����r�����dirname�basename�joinr^���r����rh����fsyncr ���r#����gitdb.constr%���r&���r(���rK���rR���rX���rc���rk���ro���rt���rx���rz���r����rF���r$���r����<module>r�������s����� ������ � � � ������� � � � ��������������������������������������������� � ������� 8�"�"�"�"�"�"�"����8��8��8�'�'�'�'�'�'�'�'��t�v�v��8��8��8��8��8��8� 8����"�� � � � � �� ���� ���� ��� ��� �� �� ���� ��� �'�/�� �7��� �w�|�� �w�� ��� ��� ���%��%��%�.��.��.� ���������������*��*��*��*��*��*��*��*�,����� �� �� �� � 2�� 2�� 2�"�������:�������(K��K��K��K����������� �� �� �� �� �� �� �� �@~��~��~��~��~��~��~��~��~��~s����?��A�A