ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/pyfakefs/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/pyfakefs/__pycache__/helpers.cpython-311.pyc

�

�܋fy3���dZddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZeeefZeeejfZej��dkZejdkZej�d��Zd	Zd
ZdZdZd
Z dZ!ejdkrda"da#nej$��a"ej%��a#de&fd�Z'de&ddfd�Z(de&fd�Z)de&ddfd�Z*d6d�Z+de,fd�Z-de
de,fd�Z.de
de,fd�Z/de
de,fd�Z0ededefd���Z1edejdefd���Z1dedefd �Z1d!eeeeeffdefd"�Z2d!eeeeeffdefd#�Z3d$ed%edefd&�Z4d'eedeefd(�Z5d)�Z6ed*ed+edefd,���Z7ed*ed+edefd-���Z7ed*ed+dddfd.���Z7d*ed+eedeefd/�Z7Gd0�d1��Z8Gd2�d3ej9��Z:Gd4�d5ej;��Z<dS)7z7Helper classes use for fake file system implementation.�N��copy)�S_IFLNK)�Union�Optional�Any�AnyStr�overload�cast�PyPy�win32z/.dockerenv���@i�i�i���returnc��tS)z/Get the global user id. Same as ``os.getuid()``��USER_ID���a/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pyfakefs/helpers.py�get_uidr/s���Nr�uidc�
�|adS)a%Set the global user id. This is used as st_uid for new files
    and to differentiate between a normal user and the root user (uid 0).
    For the root user, some permission restrictions are ignored.

    Args:
        uid: (int) the user ID of the user calling the file system functions.
    Nr)rs r�set_uidr4s
���G�G�Grc��tS)z0Get the global group id. Same as ``os.getgid()``��GROUP_IDrrr�get_gidr @s���Or�gidc�
�|adS)z�Set the global group id. This is only used to set st_gid for new files,
    no permission checks are performed.

    Args:
        gid: (int) the group ID of the user calling the file system functions.
    Nr)r!s r�set_gidr#Es
���H�H�Hrc���tjdkr td��td��dStt	j����tt	j����dS)z;Set the global user ID and group ID back to default values.r
rN)�sys�platformrr#�os�getuid�getgidrrr�	reset_idsr*PsW��
�|�w�����
�
�
���
�
�
�
�
���	��������	�������rc��tdkS)z1Return True if the current user is the root user.rrrrr�is_rootr,Zs���a�<�r�valc�,�t|t��S)z(Return True if `val` is of integer type.)�
isinstance�int�r-s r�is_int_typer2_s���c�3���rc�$�t|d��S)zLReturn True if `val` is a bytes-like object, False for a unicode
    string.�encode��hasattrr1s r�is_byte_stringr7ds���s�H�%�%�%�%rc�"�t|d��S)zLReturn True if `val` is a unicode string, False for a bytes-like
    object.r4r5r1s r�is_unicode_stringr9js���3��!�!�!r�dir_namec��dS�Nr�r:s r�make_string_pathr>p����Crc��dSr<rr=s rr>r>ur?rc�P�tttj|����Sr<)rr	r'�fspathr=s rr>r>zs�����	�(�+�+�,�,�,r�pathc�~�t|t��r'|�tjd����S|S)zzReturn the string representation of a byte string using the preferred
    encoding, or the string itself if path is a str.F)r/�bytes�decode�locale�getpreferredencoding�rCs r�	to_stringrJ~s8���$����?��{�{�6�6�u�=�=�>�>�>��Krc�t�t|t��r"t|tjd����S|S)z�Return the bytes representation of a string using the preferred
    encoding, or the byte string itself if path is a byte string.F)r/�strrErGrHrIs r�to_bytesrM�s6���$����?��T�6�6�u�=�=�>�>�>��Kr�s1�s2c��||zS)z<This is a bit of a hack to satisfy mypy - may be refactored.r)rNrOs  r�join_stringsrQ�s��
��7�Nr�encodingc�:�tjdkr
|dkr|ndS|S)z�Since Python 3.10, the new function ``io.text_encoding`` returns
    "locale" as the encoding if None is defined. This will be handled
    as no encoding in pyfakefs.)��
rGN)r%�version_info)rRs r�
real_encodingrW�s+����7�"�"�#�x�/�/�x�x�T�9��Orc�(�tj��Sr<)�timerrr�nowrZ�s���9�;�;�r�matched�stringc��dSr<r�r[r\s  r�matching_stringr_�r?rc��dSr<rr^s  rr_r_�r?rc��dSr<rr^s  rr_r_�r?rc��|�|St|t��r<t|t��r'|�t	jd����S|S)zsReturn the string as byte or unicode depending
    on the type of matched, assuming string is an ASCII string.
    NF)r/rErLr4rGrHr^s  rr_r_�sU���~��
��'�5�!�!�A�j���&=�&=�A��}�}�V�8��?�?�@�@�@��Mrc
�6�eZdZdZ	d#dedededeefd�Zde	d	efd
�Z
de	d	efd�Zd$d�Zd
e
jd	dfd�Zed	eeeffd���Zejdeeefd	dfd���Zed	eeeffd���Zejdeeefd	dfd���Zed	eeeffd���Zejdeeefd	dfd���Zed	efd���Zejded	dfd���Zed	efd���Zed	efd���Zed	efd���Zded	eefd�Zed	efd���Zejded	dfd���Zed	efd���Zejded	dfd ���Zed	efd!���Zejded	dfd"���ZdS)%�FakeStatResultz�Mimics os.stat_result for use as return type of `stat()` and similar.
    This is needed as `os.stat_result` has no possibility to set
    nanosecond times directly.
    N�
is_windows�user_id�group_id�initial_timec���d|_d|_d|_d|_||_||_d|_||_t|pddz��|_	|j	|_
|j	|_dS)Nr�e��A)�st_mode�st_ino�st_dev�st_nlink�st_uid�st_gid�_st_sizerer0�_st_atime_ns�_st_mtime_ns�_st_ctime_ns)�selfrerfrgrhs     r�__init__zFakeStatResult.__init__�sr�����%)��������
�"���#�����
� *���!$�l�&7�a�3�%>�!?�!?���!%�!2���!%�!2����r�otherrc�l�t|t��o�|j|jko�|j|jko|j|jkoo|j|jko_|j|jkoO|j|jko?|j|jko/|j	|j	ko|j
|j
ko|j|jkSr<)r/rdrrrtrs�st_sizerprornrmrlrk�rurws  r�__eq__zFakeStatResult.__eq__�s����u�n�-�-�

.��!�U�%7�7�

.��!�U�%7�7�

.��!�U�%7�7�

.����
�-�	

.�
��u�|�+�

.���u�|�+�

.��
���/�

.���u�|�+�

.���u�|�+�

.����
�-�	
rc��||kSr<rrzs  r�__ne__zFakeStatResult.__ne__�s���5�=� � rc�$�t|��}|S)ztReturn a copy where the float usage is hard-coded to mimic the
        behavior of the real os.stat_result.
        r�ru�stat_results  rrzFakeStatResult.copy�s���4�j�j���rr�c��|j|_|j|_|j|_|j|_|j|_|j|_|j	|_
dS)z�Set values from a real os.stat_result.
        Note: values that are controlled by the fake filesystem are not set.
        This includes st_ino, st_dev and st_nlink.
        N)rkrorpryrq�st_atime_nsrr�st_mtime_nsrs�st_ctime_nsrtrs  r�set_from_stat_resultz#FakeStatResult.set_from_stat_result�sS��
#�*���!�(���!�(���#�+��
�'�3���'�3���'�3����rc��|jdzS)z$Return the creation time in seconds.rj�rt�rus r�st_ctimezFakeStatResult.st_ctime����� �3�&�&rr-c�4�t|dz��|_dS)z!Set the creation time in seconds.rjN)r0rt�rur-s  rr�zFakeStatResult.st_ctime��� ��c�	�N�N����rc��|jdzS)z"Return the access time in seconds.rj�rrr�s r�st_atimezFakeStatResult.st_atimer�rc�4�t|dz��|_dS)zSet the access time in seconds.rjN)r0rrr�s  rr�zFakeStatResult.st_atime
r�rc��|jdzS)z(Return the modification time in seconds.rj�rsr�s r�st_mtimezFakeStatResult.st_mtimer�rc�4�t|dz��|_dS)z%Set the modification time in seconds.rjN)r0rsr�s  rr�zFakeStatResult.st_mtimer�rc�R�|jtztkr	|jrdS|jS)Nr)rkrrerqr�s rryzFakeStatResult.st_sizes(���<�'�!�W�,�,���,��1��}�rc��||_dSr<)rqr�s  rryzFakeStatResult.st_sizes
����
�
�
rc�x�|jrtd���d}|dz}|j|z}|j|zr|dz
}||zS)aReturn the number of 512-byte blocks allocated for the file.
        Assumes a page size of 4096 (matches most systems).
        Ignores that this may not be available under some systems,
        and that the result may differ if the file has holes.
        z4'os.stat_result' object has no attribute 'st_blocks'iir)re�AttributeErrorrq)ru�	page_size�blocks_in_page�pagess    r�	st_blockszFakeStatResult.st_blocks#s\���?�	Y� �!W�X�X�X��	�"�c�)���
��*���=�9�$�	��Q�J�E��~�%�%rc�N�|jstd���d}|j}|tjzr|tjz}|tjzr|tjz}|tjtj	zzr|tj
z}|tjzr|tjz}|S)Nz=module 'os.stat_result' has no attribute 'st_file_attributes'r)
rer�rk�stat�S_IFDIR�FILE_ATTRIBUTE_DIRECTORY�S_IFREG�FILE_ATTRIBUTE_NORMAL�S_IFCHR�S_IFBLK�FILE_ATTRIBUTE_DEVICEr�FILE_ATTRIBUTE_REPARSE_POINT)ru�moderks   r�st_file_attributesz!FakeStatResult.st_file_attributes3s�����	� �R���
����,���T�\�!�	2��D�1�1�D��T�\�!�	/��D�.�.�D��d�l�T�\�1�2�	/��D�.�.�D��T�\�!�	6��D�5�5�D��rc��|jrtjdkrtd���|jt
jzrt
jSdS)N)rT�z9module 'os.stat_result' has no attribute 'st_reparse_tag'r)rer%rVr�rkr�r�IO_REPARSE_TAG_SYMLINKr�s r�st_reparse_tagzFakeStatResult.st_reparse_tagEsO����	�#�"2�V�";�";� �N���
��<�$�,�&�	/��.�.��qr�itemc���ddl}||jkr|jS||jkr|jS||jkr|jS||jkr|jS||j	kr|j
S||jkr|jS||j
kr|jS||jkrt!|j��S||jkrt!|j��S||jkrt!|j��St-d���)z9Implement item access to mimic `os.stat_result` behavior.rNzInvalid item)r��ST_MODErk�ST_INOrl�ST_DEVrm�ST_NLINKrn�ST_UIDro�ST_GIDrp�ST_SIZEry�ST_ATIMEr0r��ST_MTIMEr��ST_CTIMEr��
ValueError)rur�r�s   r�__getitem__zFakeStatResult.__getitem__Os�������4�<����<���4�;����;���4�;����;���4�=� � ��=� ��4�;����;���4�;����;���4�<����<���4�=� � ��t�}�%�%�%��4�=� � ��t�}�%�%�%��4�=� � ��t�}�%�%�%���(�(�(rc��|jS)z&Return the access time in nanoseconds.r�r�s rr�zFakeStatResult.st_atime_nsj�
��� � rc��||_dS)z#Set the access time in nanoseconds.Nr�r�s  rr�zFakeStatResult.st_atime_nso��� ����rc��|jS)z,Return the modification time in nanoseconds.r�r�s rr�zFakeStatResult.st_mtime_nstr�rc��||_dS)z:Set the modification time of the fake file in nanoseconds.Nr�r�s  rr�zFakeStatResult.st_mtime_nsyr�rc��|jS)z(Return the creation time in nanoseconds.r�r�s rr�zFakeStatResult.st_ctime_ns~r�rc��||_dS)z6Set the creation time of the fake file in nanoseconds.Nr�r�s  rr�zFakeStatResult.st_ctime_ns�r�rr<)rrd)�__name__�
__module__�__qualname__�__doc__�boolr0r�floatrvrr{r}rr'r�r��propertyrr��setterr�r�ryr�r�r�r�r�r�r�rrrrdrd�s��������)-�3�3��3��3��	3�
�u�o�3�3�3�3�&

�C�

�D�

�

�

�

�!�C�!�D�!�!�!�!�����4���4�4�4�4�4�4��'�%��U�
�+�'�'�'��X�'��_�+�E�#�u�*�-�+�$�+�+�+��_�+��'�%��U�
�+�'�'�'��X�'��_�+�E�#�u�*�-�+�$�+�+�+��_�+��'�%��U�
�+�'�'�'��X�'��_�+�E�#�u�*�-�+�$�+�+�+��_�+��������X��

�^��3��4�����^���
&�3�
&�
&�
&��X�
&���C�����X��"�������X��)��)���
�)�)�)�)�6�!�S�!�!�!��X�!��� �s� �t� � � ��� ��!�S�!�!�!��X�!��� �s� �t� � � ��� ��!�S�!�!�!��X�!��� �s� �t� � � ��� � � rrdc�D��eZdZdZdeef�fd�Zdeddfd�Z�xZS)�BinaryBufferIOz2Stream class that handles byte contents for files.�contentsc�N��t���|pd��dS�Nr)�superrv)rur��	__class__s  �rrvzBinaryBufferIO.__init__�s%���
�������S�)�)�)�)�)r�valuerNc�0�|�|��dSr<)�write�rur�s  r�putvaluezBinaryBufferIO.putvalue�s���
�
�5�����r)	r�r�r�r�rrErvr��
__classcell__�r�s@rr�r��sp�������<�<�*��%��*�*�*�*�*�*��e����������rr�c	�~��eZdZdZ				d
deedeedeedef�fd�
Zd	efd
�Zded	dfd�Z	�xZ
S)�TextBufferIOz;Stream class that handles Python string contents for files.N�strictr��newlinerR�errorsc���tj|pd��|_t���|j|||��dSr�)�io�BytesIO�_bytestreamr�rv)rur�r�rRr�r�s     �rrvzTextBufferIO.__init__�sB����:�h�o�#�6�6���
������)�8�V�W�E�E�E�E�Errc�4�|j���Sr<)r��getvaluer�s rr�zTextBufferIO.getvalue�s����(�(�*�*�*rr�c�:�|j�|��dSr<)r�r�r�s  rr�zTextBufferIO.putvalue�s������u�%�%�%�%�%r)NNNr�)r�r�r�r�rrErLrvr�r�r�r�s@rr�r��s��������E�E�%)�!%�"&��F�F��5�/�F��#��F��3�-�	F�
�F�F�F�F�F�F�+�%�+�+�+�+�&�e�&��&�&�&�&�&�&�&�&rr�)rN)=r�r�rGr'r&r�r%rYrr�typingrrrr	r
rrLrE�	AnyString�PathLike�AnyPath�python_implementation�IS_PYPY�IS_WINrC�exists�	IN_DOCKER�	PERM_READ�
PERM_WRITE�PERM_EXE�PERM_DEF�
PERM_DEF_FILE�PERM_ALLrrr(r)r0rrr r#r*r�r,r2r7r9r>rJrMrQrWrZr_rdr�r��
TextIOWrapperr�rrr�<module>r�s��>�=�	�	�	�	�
�
�
�
�	�	�	�	���������
�
�
�
�����������������?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?��#�u�*��	�
����#�
$��
(�(�
(�
*�
*�f�
4��	���	 ���G�N�N�=�)�)�	��	�
�
������
����<�7����G��H�H��b�i�k�k�G��r�y�{�{�H�������
	��	��	�	�	�	�������
������������������
 �S� �T� � � � �
&��&��&�&�&�&�"�3�"�4�"�"�"�"�
��v��&����
���
��r�{��s����
���-�w�-�6�-�-�-�-��E�&�%��U�
�"3�3�4��������5���s�E�z�!2�2�3��������V����F�����
�H�S�M��h�s�m��������
��U��F��u����
���
��S��&��S����
���
��V��T��d����
���
�
�
�%�f�-�
�
�i��
�
�
�
�J �J �J �J �J �J �J �J �Z�����R�Z����&�&�&�&�&�2�#�&�&�&�&�&r

Zerion Mini Shell 1.0