Your IP : 18.221.147.141


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/pyfakefs/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/pyfakefs/__pycache__/fake_open.cpython-311.pyc

�

��bgH4�	���dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZmZmZddlmZmZmZmZerdd	lmZed
d��Zdd
ddddddd�ZGd�d��Z dS)zGA fake open() function replacement. See ``fake_filesystem`` for usage.
�N)�
namedtuple)�S_ISDIR)�Optional�Union�Any�Tuple�cast�AnyStr�
TYPE_CHECKING)�helpers)�FakePipeWrapper�FakeFileWrapper�FakeFile�AnyFileWrapper)�	AnyString�is_root�	PERM_READ�
PERM_WRITE)�FakeFilesystem�
_OpenModesz<must_exist can_read can_write truncate append must_not_exist)TTFFFF)FFTTFF)FFTFTF)TTTFFF)FTTTFF)FTTFTF)FFTFFT)FTTFFT)�r�w�azr+zw+za+�xzx+c��eZdZdZdZ		d!dddedefd�Zded	ed
efd�Z								d"de	e
efdedede
ede
ede
ededede
ed
efd�Zeded
efd���Zde
ede
deded
ef
d�Zde	e
efd
ee
ee
e
e
ee
e
ffd�Zdede
ede
ed
ee
eeffd �ZdS)#�FakeFileOpenz�Faked `file()` and `open()` function replacements.

    Returns FakeFile objects in a FakeFilesystem in place of the `file()`
    or `open()` function.
    F�
filesystemr�delete_on_close�raw_ioc�0�||_||_||_dS)z�
        Args:
          filesystem:  FakeFilesystem used to provide file system information
          delete_on_close:  optional boolean, deletes file on close()
        N)r�_delete_on_closer)�selfrrrs    �c/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pyfakefs/fake_open.py�__init__zFakeFileOpen.__init__Ps��%��� /���������args�kwargs�returnc��|j|i|��S)z:Redirects calls to file() or open() to appropriate method.)�call)r"r&r's   r#�__call__zFakeFileOpen.__call___s���t�y�$�)�&�)�)�)r%r���NT�file_�mode�	buffering�encoding�errors�newline�closefd�opener�
open_modesc
���d|v}
|
r|rtd���|�|||	��\}}	|�*|jdkr|||�|	����}|�|��\}}}
}|��|��|
�/t|jj��|
ks|jj|
sttj
d���|jj|
}|�J�|d}t|t��sJ�t|j|j
|j|��}|j�|��}||_|S|�J�|
sd}|sT|	jrM|s&|j�|��r1|jjs%|j�tj|��|�J�|�|||	|��}t/|j��rW|jjr&|j�tj|��n%|j�tj|��||_|	jr-t;j��}||_|jjs||_ tC|||	j|	j"|	j#|j$|j||
|||||j%���}|
�3|
|_|jj|
}|�J�|�#|��n|j�|��|_|S)	a�Return a file-like object with the contents of the target
        file object.

        Args:
            file_: Path to target file or a file descriptor.
            mode: Additional file modes (all modes in `open()` are supported).
            buffering: the buffer size used for writing. Data will only be
                flushed if buffer size is exceeded. The default (-1) uses a
                system specific default buffer size. Text line mode (e.g.
                buffering=1 in text mode) is not supported.
            encoding: The encoding used to encode unicode strings / decode
                bytes.
            errors: (str) Defines how encoding errors are handled.
            newline: Controls universal newlines, passed to stream object.
            closefd: If a file descriptor rather than file name is passed,
                and this is set to `False`, then the file descriptor is kept
                open when file is closed.
            opener: an optional function object that will be called with
                `file_` and the open flags (derived from `mode`) and returns
                a file descriptor.
            open_modes: Modes for opening files if called from low-level API.

        Returns:
            A file-like object containing the contents of the target file.

        Raises:
            OSError depending on Python version / call mode:
                - if the target object is a directory
                - on an invalid path
                - if the file does not exist when it should
                - if the file exists but should not
                - if permission is denied
            ValueError: for an invalid mode or mode combination
        �bz-binary mode doesn't take an encoding argumentN�pathlibzinvalid pipe file descriptorrT)�update�read�appendrrr2�binaryr3r0r1r/r)&�
ValueError�_handle_file_mode�
__module__�_open_flags_from_open_modes�_handle_file_arg�lenr�
open_files�OSError�errno�EBADF�
isinstancer
�fd�	can_write�_add_open_file�filedes�must_not_exist�islink�
is_windows_fs�raise_os_error�EEXIST�_init_file_objectr�st_mode�EACCES�EISDIR�	opened_as�truncater�now�st_mtime�st_ctimer�can_readr;r!r)r"r-r.r/r0r1r2r3r4r5r<�file_object�	file_pathrK�	real_path�wrappers�existing_wrapper�wrapper�file_des�current_time�fakefile�open_files_lists                      r#r*zFakeFileOpen.callcs`��\�����	N�h�	N��L�M�M�M�"�4�4�T�7�J�O�O����
��&�"3�y�"@�"@��F�5�$�"B�"B�:�"N�"N�O�O�E�59�5J�5J�5�5Q�5Q�2��Y�����9�#4����t��1�2�2�g�=�=���1�'�:�>��e�k�+I�J�J�J���1�'�:�H��'�'�'�'��{���.��@�@�@�@�@�%��� �#� �*��	��G���5�5�g�>�>�H�&�G�O��N��$�$�$��	��G��		D��)�		D��			D�
�?�)�)�)�4�4�		D���5�
		D�
�O�*�*�5�<��C�C�C��$�$�$��,�,���J�	�
�
���;�&�'�'�	H���,�
H���.�.�u�|�Y�G�G�G�G���.�.�u�|�Y�G�G�G�!*�����	4�"�;�=�=�L�#/�K� ��?�0�
4�'3��$�"����'��$��$� �1����������;�
�
�
�� ��&�H��"�o�8��A�O�"�.�.�.��"�"�8�,�,�,�,�#��=�=�h�G�G�H���r%c�l�d}|jr|jr|tjz}n-|jr|tjz}n|jr|tjz}|jr|tjz}|jr|tj	z}|j
s|jr|tjz}|jr|jr|tj
z}|S)Nr)rZrI�os�O_RDWR�O_RDONLY�O_WRONLYr;�O_APPENDrV�O_TRUNC�
must_exist�O_CREATrL�O_EXCL)r5�flagss  r#r@z(FakeFileOpen._open_flags_from_open_modes�s�������	!�:�#7�	!��R�Y��E�E�
�
 �	!��R�[� �E�E�
�
!�	!��R�[� �E���	!��R�[� �E���	 ��R�Z��E��$�	 ��)=�	 ��R�Z��E��$�	��)=�	��R�Y��E��r%r[r\r]c�>�|r�t��sQ|jr|jtzr|jr4|jt
zs%|j�tj	|��|jr|j
r|�d���n|jr%|j�tj
|��|j�|��r@|j�|d���}|j�J�t#t$|j��}n|}|j�|��rW|jjrtjn#|jjrtj
ntj}|j�||��|j�|dd���}|S)N�F)�follow_symlinksT)�create_missing_dirs�apply_umask)rrZrRrrIrrrOrErSrV�set_contentsrl�ENOENTrM�resolve�contentsr	r
�ends_with_path_separatorrN�EINVAL�is_macosrT�create_file_internally)r"r[r\r5r]�link_object�target_path�errors        r#rQzFakeFileOpen._init_file_objects����	��9�9�
H��$�
H�-8�-@�9�-L�
H��(�
H�1<�1D�z�1Q�
H���.�.�u�|�Y�G�G�G��#�
1��&�1��,�,�R�0�0�0���$�
H���.�.�u�|�Y�G�G�G���%�%�i�0�0�
(�"�o�5�5�i�QV�5�W�W��"�+�7�7�7�"��K�0�����(����7�7��D�D�
A���4�&�E�L�L���/�&���������.�.�u�i�@�@�@��/�@�@��u�$�A���K��r%c���d}t|t��r�|}|j�|��}t|t��rdd|dfSt|t
��r|j|_tt|j�|���
����}|�J�|j}|tt|��|tt|��fStt|��}||jj
jkr|jj
}|}nP|j�|��}|j�|��r|j�|d���}||d|fS)NF)�check_read_perm)rG�intr�
get_open_filer
rrr!r	r�
get_object�namer
�dev_null�resolve_path�exists�get_object_from_normpath)r"r-r[rKr`�pathr\r]s        r#rAzFakeFileOpen._handle_file_arg1sy�����e�S�!�!�	� �G��o�3�3�G�<�<�G��'�?�3�3�
1��T�7�D�0�0��'�?�3�3�
@�(/�(?��%���$�/�7�7��@�@�K�K�M�M���K��*�*�*��#�D���V�T�"�"���V�T�"�"�	�
����'�'�	����0�5�5�5��/�2�K�!�I�I���4�4�Y�?�?�I���%�%�i�0�0�
�"�o�F�F��u�G�����I�t�Y�6�6r%c��|}d|vrd|vstjdkrd|vrtd|z���|�dd���dd��}|�dd���dd��}|js/|t
vrtd	|z���t
t
|�}|�J�||fS)
Nr7�t)��
�UzInvalid mode: rq�rUrzInvalid mode: %r)�sys�version_infor=�replacer�_OPEN_MODE_MAPr)r"r.r2r5�
orig_modess     r#r>zFakeFileOpen._handle_file_modeVs����
��4�K�K�C�4�K�K���w�&�&�3�$�;�;��-��4�5�5�5��|�|�C��$�$�,�,�S�"�5�5���|�|�D�#�&�&�.�.�s�C�8�8���{�	;��>�)�)� �!3�j�!@�A�A�A�#�^�D�%9�:�J��%�%�%��
�"�"r%)FF)rr,NNNTNN)�__name__r?�__qualname__�__doc__�boolr$rrr+rr
r��strrrr*�staticmethodr@rrrQrrAr>�r%r#rrGsb���������H�
!&��	
�
�$�
��
��	
�
�
�
�*�c�*�S�*�^�*�*�*�*���"&� $�!%���+/�O�O��V�S�[�!�O��O��	O�
�3�-�O���
�
O��#��O��O��O��Z�(�O�
�O�O�O�O�b��
��s�����\��&'��h�'�'��'��	'�
�'�
�
'�'�'�'�R#7��6�3�;�'�#7�	�x��!�8�F�#3�X�c�]�H�V�DT�T�	U�#7�#7�#7�#7�J#��#��#��#��Z�(�	#�

�x��}�j�(�	)�#�#�#�#�#�#r%r)!r�rErfr��collectionsr�statr�typingrrrrr	r
r�pyfakefsr�pyfakefs.fake_filer
rrr�pyfakefs.helpersrrrr�pyfakefs.fake_filesystemrrr�rr�r%r#�<module>r�s���������	�	�	�	�
�
�
�
�"�"�"�"�"�"��������������������������������������������������������8�7�7�7�7�7�7��Z��B���
�
2�	1�	1�
1�
1�
1�	1�
1����b#�b#�b#�b#�b#�b#�b#�b#�b#�b#r%

?>