Edit File: fake_open.cpython-311.pyc
� ����n�dH4��������������� ��������������d�Z�ddlZddlZddlZddlmZ�ddlmZ�ddlm Z m Z mZmZm Z mZmZ�ddlmZ�ddlmZmZmZmZ�ddlmZmZmZmZ�erdd lmZ��ed d������������Zdd ddddddd�Z�G�d��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������������������������e�Zd�ZdZd�Z� � �d!dddedefd�Zded ed efd�Z � � � � � � � �d"de e ef���������dedede e���������de e���������de e���������dedede e���������d efd�Zeded efd���������������Zde e���������de deded ef d�Zde e ef���������d ee e���������e e ���������e e���������e e ���������f���������fd�Zdede e���������de e���������d ee e���������ef���������fd �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���)�selfr���r���r���s��� �c/builddir/build/BUILD/cloudlinux-venv-1.0.2/venv/lib/python3.11/site-packages/pyfakefs/fake_open.py�__init__zFakeFileOpen.__init__P���s�������%��� /�������������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|rt����������d�������������|����������������������||| ������������\��}} |�*|j��������dk����r�|||����������������������| ������������������������}|����������������������|������������\��}}} }|��|��| �/t����������|�j��������j��������������������| k����s|�j��������j��������| ���������st����������t����������j ��������d�������������|�j��������j��������| ���������}|�J��|d���������}t����������|t����������������������sJ��t����������|�j��������|j ��������|j��������|������������}|�j�����������������������������|������������}||_��������|S�|�J��| sd}|sT| j��������rM|s&|�j�����������������������������|������������r1|�j��������j��������s%|�j�����������������������������t����������j��������|�������������|�J��|����������������������||| |������������}t/����������|j��������������������rW|�j��������j��������r&|�j�����������������������������t����������j��������|�������������n%|�j�����������������������������t����������j��������|�������������||_��������| j��������r-t;����������j����������������������}||_��������|�j��������j��������s||_ ��������tC����������||| j��������| j"��������| j#��������|�j$��������|�j��������|| |||||�j%���������������������}| �3| |_��������|�j��������j��������| ���������}|�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 descriptorr���T)�update�read�appendr���r���r2����binaryr3���r0���r1���r/���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/���r0���r1���r2���r3���r4���r5���r<����file_object� file_pathrK���� real_path�wrappers�existing_wrapper�wrapper�file_des�current_time�fakefile�open_files_lists��� r#���r*���zFakeFileOpen.callc���s`�����\������� 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}|�j���������r|�j��������r|t����������j��������z��}n-|�j���������r|t����������j��������z��}n|�j��������r|t����������j��������z��}|�j��������r|t����������j��������z��}|�j��������r|t����������j ��������z��}|�j ��������s|�j��������r|t����������j��������z��}|�j��������r|�j��������r|t����������j ��������z��}|S�)Nr���)rZ���rI����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|j��������r|j��������t����������z��r|j��������r4|j��������t ����������z��s%|�j�����������������������������t����������j ��������|�������������|j��������r|j ��������r|���������������������d��������������n|j��������r%|�j�����������������������������t����������j ��������|�������������|�j�����������������������������|������������r@|�j�����������������������������|d�������������}|j���������J��t#����������t$����������|j��������������������}n|}|�j�����������������������������|������������rW|�j��������j��������rt����������j��������n#|�j��������j��������rt����������j ��������nt����������j��������}|�j�����������������������������||�������������|�j�����������������������������|dd�������������}|S�)N��F)�follow_symlinksT)�create_missing_dirs�apply_umask)r���rZ���rR���r���rI���r���r���rO���rE���rS���rV����set_contentsrl����ENOENTrM����resolve�contentsr ���r ����ends_with_path_separatorrN����EINVAL�is_macosrT����create_file_internally)r"���r[���r\���r5���r]����link_object�target_path�errors��� r#���rQ���zFakeFileOpen._init_file_object��s��������� ��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����������������������rd�d�|d�fS�t����������|t ����������������������r|j��������|�_��������t����������t����������|�j�����������������������������|������������� ����������������������������������������������}|�J��|j��������}|t����������t����������|������������|t����������t����������|������������fS�t����������t����������|������������}||�j��������j ��������j��������k����r|�j��������j ��������}|}nP|�j�����������������������������|������������}|�j�����������������������������|������������r|�j�����������������������������|d�������������}||d�|fS�)NF)�check_read_perm)rG����intr���� get_open_filer ���r���r���r!���r ���r���� get_object�namer ����dev_null�resolve_path�exists�get_object_from_normpath)r"���r-���r[���rK���r`����pathr\���r]���s��� r#���rA���zFakeFileOpen._handle_file_arg1��sy���������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|v�rd|v�st�����������j��������dk����rd|v�rt����������d|z����������������|���������������������dd���������������������������������dd������������}|���������������������dd���������������������������������dd������������}|�j��������s/|t ����������vrt����������d |z���������������t ����������t ����������|�����������}|�J��||fS�) Nr7����t)����� ����UzInvalid mode: rq����rUr���zInvalid mode: %r)�sys�version_infor=����replacer����_OPEN_MODE_MAPr���)r"���r.���r2���r5���� orig_modess��� r#���r>���zFakeFileOpen._handle_file_modeV��s��������� ��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)r���r,���NNNTNN)�__name__r?����__qualname__�__doc__�boolr$���r���r���r+���r���r ���r�����strr���r���r*����staticmethodr@���r���r���rQ���r���rA���r>�����r%���r#���r���r���G���sb������������������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����rE���rf���r�����collectionsr����statr����typingr���r���r���r���r ���r ���r����pyfakefsr����pyfakefs.fake_filer ���r���r���r����pyfakefs.helpersr���r���r���r����pyfakefs.fake_filesystemr���r���r����r���r����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%���