HEX
Server: Apache
System: Linux sg2plmcpnl492417.prod.sin2.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: nyiet8349bzl (9207396)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/pyfakefs/__pycache__/fake_file.cpython-311.pyc
�

�|oiN����dZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZmZmZmZmZddlmZddlmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(erddl)m*Z*ej+Z,ed	Z-ed
Z.Gd�de/��Z0Gd
�d��Z1Gd�de1��Z2Gd�de1��Z3Gd�de1��Z4Gd�de4��Z5Gd�d��Z6Gd�d��Z7Gd�d��Z8Gd�d��Z9dS)z0Fake implementations for different file objects.�N)�S_IFREG�S_IFDIR)�
TracebackType)
�List�Optional�Callable�Union�Any�Dict�cast�AnyStr�NoReturn�Iterator�TextIO�Type�
TYPE_CHECKING)�helpers)
�FakeStatResult�BinaryBufferIO�TextBufferIO�is_int_type�is_unicode_string�	to_string�matching_string�
real_encoding�AnyPath�	AnyString�get_locale_encoding�
_OpenModes�is_root)�FakeFilesystem)�FakeFileWrapper�FakeDirWrapper�StandardStreamWrapper�FakePipeWrapper)�FakeFile�
FakeDirectoryc�,��eZdZdZdeddf�fd�Z�xZS)�FakeLargeFileIoExceptionz|Exception thrown on unsupported operations for fake large files.
    Fake large files have a size with no real content.
    �	file_path�returnNc�P��t���d|z��dS)Nz?Read and write operations not supported for fake large file: %s)�super�__init__)�selfr*�	__class__s  ��d/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pyfakefs/fake_file.pyr.z!FakeLargeFileIoException.__init__Qs6���
�����
"�$-�
.�	
�	
�	
�	
�	
�)�__name__�
__module__�__qualname__�__doc__�strr.�
__classcell__�r0s@r1r)r)LsU���������
�#�
�$�
�
�
�
�
�
�
�
�
�
r2r)c�H��eZdZdZdZeejzddddddfdede	de
ede
dd	e
ed
e
ede
edgdfde
e
fd
�Zede
efd���Zede
efd���Zedefd���Zejdeddfd���Zedefd���Zejdeddfd���Zedefd���Zejdeddfd���Zde	ddfd�Zde	ddfd�Zdefd�Zdeeedfde
efd�Zdedefd�Zd-ded	e
edefd�Zede	fd ���Z e jde	ddfd!���Z edefd"���Z!e"j#d#kredefd$���Z$d%ede%f�fd&�Z&d'ed(e%ddf�fd)�Z'defd*�Z(d+e	defd,�Z)�xZ*S).r&a�Provides the appearance of a real file.

    Attributes currently faked out:
      * `st_mode`: user-specified, otherwise S_IFREG
      * `st_ctime`: the time.time() timestamp of the file change time (updated
        each time a file's attributes is modified).
      * `st_atime`: the time.time() timestamp when the file was last accessed.
      * `st_mtime`: the time.time() timestamp when the file was last modified.
      * `st_size`: the size of the file
      * `st_nlink`: the number of hard links to the file
      * `st_ino`: the inode number - a unique number identifying the file
      * `st_dev`: a unique number identifying the (fake) file system device
        the file belongs to
      * `st_uid`: always set to USER_ID, which can be changed globally using
            `set_uid`
      * `st_gid`: always set to GROUP_ID, which can be changed globally using
            `set_gid`

    .. note:: The resolution for `st_ctime`, `st_mtime` and `st_atime` in the
        real file system depends on the used file system (for example it is
        only 1s for HFS+ and older Linux file systems, but much higher for
        ext4 and NTFS). This is currently ignored by pyfakefs, which uses
        the resolution of `time.time()`.

        Under Windows, `st_atime` is not updated for performance reasons by
        default. pyfakefs never updates `st_atime` under Windows, assuming
        the default setting.
    )
�st_mode�st_ino�st_dev�st_nlink�st_uid�st_gid�st_size�st_atime�st_mtime�st_ctime�st_atime_ns�st_mtime_ns�st_ctime_nsN�namer;�contents�
filesystemr!�encoding�errors�side_effect�
open_modesc	�>�|�td���||_||_||_t	|jt
j��t
j��t
j	����|_
|dz	dkr
|tz}||j
_d|_
t|��|_|pd|_|�|��|_|j�t'|j��nd|j
_
d|_d|_i|_d|_||_dS)aY
        Args:
            name: Name of the file/directory, without parent path information
            st_mode: The stat.S_IF* constant representing the file type (i.e.
                stat.S_IFREG, stat.S_IFDIR), and the file permissions.
                If no file type is set (e.g. permission flags only), a
                regular file type is assumed.
            contents: The contents of the filesystem object; should be a string
                or byte object for regular files, and a dict of other
                FakeFile or FakeDirectory objects with the file names as
                keys for FakeDirectory objects
            filesystem: The fake filesystem where the file is created.
            encoding: If contents is a unicode string, the encoding used
                for serialization.
            errors: The error mode used for encoding/decoding errors.
            side_effect: function handle that is executed when file is written,
                must accept the file object as an argument.
            open_modes: The modes the file was opened with (e.g. can read, write etc.)
        Nzfilesystem shall not be None�r�strict�)�
ValueErrorrJ�_side_effectrHr�
is_windows_fsr�get_uid�get_gid�now�stat_resultrr;rArrKrL�_encode_contents�_byte_contents�len�epoch�
parent_dir�xattr�	opened_asrN)	r/rHr;rIrJrKrLrMrNs	         r1r.zFakeFile.__init__�s��>���;�<�<�<�,6���0;��� ��	�)��$��O����O����K�M�M�	
�
����b�=�A����w��G�#*��� ����'4�X�'>�'>��
�!�-�X���/3�/D�/D�X�/N�/N���(,�(;�(G�C��#�$�$�$�Q�	
�� ���
�37�����
�$&���$����r2r+c��|jS)z&Return the contents as raw byte array.�r[�r/s r1�
byte_contentszFakeFile.byte_contents�s
���"�"r2c��t|jt��r4|j�|jp
t��|j���SdS)z9Return the contents as string with the original encoding.)rLN)�
isinstancerd�bytes�decoderKrrLrcs r1rIzFakeFile.contents�sV���d�(�%�0�0�	��%�,�,��
�6�!4�!6�!6��{�-���
��tr2c��|jjS)z*Return the creation time of the fake file.�rYrDrcs r1rDzFakeFile.st_ctime������(�(r2�valc��||j_dS)z'Set the creation time of the fake file.Nrj�r/rls  r1rDzFakeFile.st_ctime����%(���!�!�!r2c��|jjS)z(Return the access time of the fake file.�rYrBrcs r1rBzFakeFile.st_atime�rkr2c��||j_dS)z%Set the access time of the fake file.Nrqrns  r1rBzFakeFile.st_atime�ror2c��|jjS)z.Return the modification time of the fake file.�rYrCrcs r1rCzFakeFile.st_mtime�rkr2c��||j_dS)z+Set the modification time of the fake file.Nrtrns  r1rCzFakeFile.st_mtime�ror2rAc���|�|��|jrd|_|jr&|j�||j|j��||_d|_dS)a"Sets the self.st_size attribute and replaces self.content with `None`.

        Provided specifically to simulate very large files without regards
        to their content (which wouldn't fit in memory).
        Note that read/write operations with such a file raise
            :py:class:`FakeLargeFileIoException`.

        Args:
          st_size: (int) The desired file size

        Raises:
          OSError: if ``st_size`` is not a non-negative integer,
                   or if ``st_size`` exceeds the available file system space
        rN)�_check_positive_intrA�sizerJ�change_disk_usagerHr=r[�r/rAs  r1�set_large_file_sizezFakeFile.set_large_file_size�sg��	
� � ��)�)�)��<�	��D�I��?�	O��O�-�-�g�t�y�$�+�N�N�N����"����r2rxc��t|��r|dkr,|j�tj|j��dSdS�Nr)rrJ�raise_os_error�errno�ENOSPCrH)r/rxs  r1rwzFakeFile._check_positive_intsD���4� � �	D�D�1�H�H��O�*�*�5�<���C�C�C�C�C�%-�Hr2c��|jduS)zVReturn `True` if this file was initialized with size
        but no contents.
        Nrbrcs r1�
is_large_filezFakeFile.is_large_file
s���"�d�*�*r2c���t|��r<ttt|��|jp
t��|j��}tt|��S�N)rrgrr7rKrrL�r/rIs  r1rZzFakeFile._encode_contentssV���X�&�&�	���S�(�#�#��
�6�!4�!6�!6�����H�
�E�8�$�$�$r2c��|�|��}|j|k}|rt|��nd}|jpd}|j�||z
|j|j��||_||_|xjdz
c_|S)a�Sets the file contents and size.
           Called internally after initial file creation.

        Args:
            contents: string, new content of file.

        Returns:
            `True` if the contents have been changed.

        Raises:
              OSError: if the `st_size` is not a non-negative integer,
                   or if `st_size` exceeds the available file system space
        r�)	rZr[r\rArJryrHr=r])r/rIrd�changedrA�current_sizes      r1�set_initial_contentszFakeFile.set_initial_contentss����-�-�h�7�7�
��%��6��(5�<�#�m�$�$�$�1���|�(�q����)�)��l�"�D�I�t�{�	
�	
�	
�,�������
�
�a��
�
��r2c��t|��|_|�|��}|j�|�|��|S)ajSets the file contents and size and increases the modification time.
        Also executes the side_effects if available.

        Args:
          contents: (str, bytes) new content of file.
          encoding: (str) the encoding to be used for writing the contents
                    if they are a Unicode string.
                    If not given, the locale preferred encoding is used.

        Returns:
            `True` if the contents have been changed.

        Raises:
          OSError: if `st_size` is not a non-negative integer,
                   or if it exceeds the available file system space.
        )rrKr�rT)r/rIrKr�s    r1�set_contentszFakeFile.set_contents4sH��"&�h�/�/��
��+�+�H�5�5����(����d�#�#�#��r2c��|jS)z.Return the size in bytes of the file contents.)rArcs r1rxz
FakeFile.sizeKs���|�r2c�2�|�|��|jpd}|j�||z
|j|j��|jr1||kr|jd|�|_n|xjd||z
zz
c_||_|xjdz
c_dS)a:Resizes file content, padding with nulls if new size exceeds the
        old size.

        Args:
          st_size: The desired size for the file.

        Raises:
          OSError: if the st_size arg is not a non-negative integer
                   or if st_size exceeds the available file system space
        rN�r�)rwrArJryrHr=r[r])r/rAr�s   r1rxz
FakeFile.sizePs���	
� � ��)�)�)��|�(�q����)�)��l�"�D�I�t�{�	
�	
�	
���	H���%�%�&*�&9�(�7�(�&C��#�#��#�#�u��,�0F�'G�G�#�#�����
�
�a��
�
�
�
r2c���g}|}|r7|�dt|j|j����|j}|�7|j�|d��}|d|krR|�d��|�|��}|j�|��d}|s||z}n|�|��}|j�	|��S)z+Return the full path of the current object.r)
�insertrrHr^rJ�get_path_separator�pop�join�
splitdrive�absnormpath)r/�names�obj�sep�dir_path�drives      r1�pathz
FakeFile.pathjs���!��"&���	!��L�L��O�D�I�s�x�@�@�A�A�A��.�C��	!��o�0�0��q��:�:����8�s�?�?��I�I�a�L�L�L��x�x����H��O�.�.�x�8�8��;�E��
*���>����x�x����H���*�*�8�4�4�4r2)�rPc�@�|j�|j��Sr�)rJ�
isjunctionr�rcs r1�is_junctionzFakeFile.is_junction�s���?�-�-�d�i�8�8�8r2�itemc���||jvrt|j|��St���|��S�z'Forward some properties to stat_result.)�
stat_types�getattrrYr-�__getattribute__)r/r�r0s  �r1�__getattr__zFakeFile.__getattr__�s;����4�?�"�"��4�+�T�2�2�2��w�w�'�'��-�-�-r2�key�valuec���||jvrt|j||��St���||��Sr�)r��setattrrYr-�__setattr__)r/r�r�r0s   �r1r�zFakeFile.__setattr__�s?����$�/�!�!��4�+�S�%�8�8�8��w�w�"�"�3��.�.�.r2c�(�|j�d|jd�d�S)N�(�o�))rHr;rcs r1�__str__zFakeFile.__str__�s ���)�1�1���1�1�1�1�1r2�permission_bitsc���tj��|jjkr|j|z|kStj��|jjkr|j|dz	z|dz	kS|j|dz	z|dz	kS)aChecks if the given permissions are set in the fake file.

        Args:
            permission_bits: The permission bits as set for the user.

        Returns:
            `True` if the permissions are set in the correct class (user/group/other).
        r��)rrVrYr?r;rWr@)r/r�s  r1�has_permissionzFakeFile.has_permission�s����?���� 0� 7�7�7��<�/�1�_�D�D��?���� 0� 7�7�7��<�?�a�#7�8�O�q�<P�P�P��|��!�3�4��1�8L�L�Lr2r�)+r3r4r5r6r�rr�
PERM_DEF_FILEr
�intrr7rrr.�propertyrgrdrI�floatrD�setterrBrCr{rw�boolr�r	rZr�r�rxr��sys�version_infor�r
r�r�r�r�r8r9s@r1r&r&Xs����������:�J�&��!6�6�%)�15�"&� $�>B�+/�9%�9%��9%��9%��6�"�	9%�
�-�.�9%��3�-�
9%���
�9%��h�
�|�T�'9�:�;�9%��Z�(�9%�9%�9%�9%�v�#�x���#�#�#��X�#���(�3�-�����X���)�%�)�)�)��X�)��_�(�E�(�d�(�(�(��_�(��)�%�)�)�)��X�)��_�(�E�(�d�(�(�(��_�(��)�%�)�)�)��X�)��_�(�E�(�d�(�(�(��_�(�#�3�#�4�#�#�#�#�.D��D��D�D�D�D�
+�t�+�+�+�+�%��s�E�4�/?�)@�%�X�e�_�%�%�%�%��V�������6��V��x��}��PT�����.��c�����X��
�[��C��D�����[��2�5�f�5�5�5��X�5�(��7�"�"�	�	9��	9�	9�	9�
��	9�.��.��.�.�.�.�.�.�/�s�/�3�/�4�/�/�/�/�/�/�2��2�2�2�2�
M�c�
M�d�
M�
M�
M�
M�
M�
M�
M�
Mr2r&c�L��eZdZd	�fd�Zedefd���Zdedefd�Z	�xZ
S)
�FakeNullFilerJr!r+Nc�Z��t���|j|d���dS)NrR)rJrI)r-r.�devnull)r/rJr0s  �r1r.zFakeNullFile.__init__�s+���
������+�
�R��P�P�P�P�Pr2c��dS)Nr2�rcs r1rdzFakeNullFile.byte_contents�s���sr2rIc��dS)NFr�r�s  r1r�z!FakeNullFile.set_initial_contents�s���ur2)rJr!r+N)r3r4r5r.r�rgrdr
r�r�r8r9s@r1r�r��s��������Q�Q�Q�Q�Q�Q���u�����X���V����������r2r�c	�~��eZdZdZ	ddedddeeddf�fd�
Zedee	fd	���Z
d�fd
�	Zd�Z�xZ
S)
�FakeFileFromRealFileztRepresents a fake file copied from the real file system.

    The contents of the file are read on demand only.
    Nr*rJr!rMr+c���t���tj�|��||���d|_dS)a3
        Args:
            file_path: Path to the existing file.
            filesystem: The fake filesystem where the file is created.

        Raises:
            OSError: if the file does not exist in the real file system.
            OSError: if the file already exists in the fake file system.
        )rHrJrMFN)r-r.�osr��basename�
contents_read)r/r*rJrMr0s    �r1r.zFakeFileFromRealFile.__init__�sO���	�������!�!�)�,�,�!�#�	�	
�	
�	
�
#����r2c��|jsMd|_t|jd��5}|���|_ddd��n#1swxYwYtj|j��j|_|jS)NT�rb)r��io_openr*�readr[r��statrB)r/�fs  r1rdz"FakeFileFromRealFile.byte_contents�s����!�	/�!%�D������.�.�
/�!�&'�f�f�h�h��#�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/�����/�/�8��
��"�"s�A
�
A�Ac�Z��d|_t���||��dS�NT)r�r-r�)r/rIrKr0s   �r1r�z!FakeFileFromRealFile.set_contents�s+���!���
�����X�x�0�0�0�0�0r2c��dS)zThe contents are never faked.Fr�rcs r1r�z"FakeFileFromRealFile.is_large_file�����ur2r�)r3r4r5r6r7rrr.r�rgrdr�r�r8r9s@r1r�r��s����������+/�	#�#��#�%�#��h�'�	#�

�#�#�#�#�#�#�,�#�x���#�#�#��X�#�1�1�1�1�1�1�������r2r�c�j��eZdZdZejdfdedededfd�Z	dde
d	eed
efd�Ze
d
eeeffd���Ze
d
eefd
���Zded
dfd�Zded
efd�Zded
efd�Zddeded
dfd�Ze
d
efd���Zejded
dfd���Zddd
efd�Zd
ef�fd�Z�xZS)r'z,Provides the appearance of a real directory.NrH�	perm_bitsrJr!c��t�||t|zd|���|xjdz
c_i|_dS)a
        Args:
            name:  name of the file/directory, without parent path information
            perm_bits: permission bits. defaults to 0o777.
            filesystem: if set, the fake filesystem where the directory
                is created
        rR)rJr�N)r&r.rr>�_entries)r/rHr�rJs    r1r.zFakeDirectory.__init__�sE��	���$��g�	�&9�2�*��U�U�U�	
�
�
���
�
�,.��
�
�
r2rIrKr+c�V�|j�tj|j���r��rJr~r�EISDIRr�)r/rIrKs   r1r�zFakeDirectory.set_contents�s���o�,�,�U�\�4�9�E�E�Er2c��|jS)z/Return the list of contained directory entries.)r�rcs r1�entrieszFakeDirectory.entries�s���}�r2c�h�d�t|j���d����D��S)z^Return the list of contained directory entry names ordered by
        creation order.
        c��g|]
}|d��S�rr���.0r�s  r1�
<listcomp>z.FakeDirectory.ordered_dirs.<locals>.<listcomp>s,��
�
�
��
��G�
�
�
r2c��|djS)Nr�)r<)�entrys r1�<lambda>z,FakeDirectory.ordered_dirs.<locals>.<lambda>s���a���r2)r�)�sortedr��itemsrcs r1�ordered_dirszFakeDirectory.ordered_dirs�sB��

�
��t�}�2�2�4�4�:W�:W�X�X�X�
�
�
�	
r2�path_objectc��tj��sU|jjsI|�tj��s*|j�tj|j	��t|j��}||jvr*|j�tj
|j	��||j|<||_|j�&|jxjdz
c_|jj|_|xjdz
c_|xjdz
c_|j|_|jdkr-|j�|j|j|j��dSdS)a5Adds a child FakeFile to this directory.

        Args:
            path_object: FakeFile instance to add as a child of this directory.

        Raises:
            OSError: if the directory has no write permission (Posix only)
            OSError: if the file or directory to be added already exists
        Nr�)rr rJrUr��
PERM_WRITEr~r�EACCESr�rrHr��EEXISTr�r^r<�last_inor>r=ryrx)r/r��path_object_names   r1�	add_entryzFakeDirectory.add_entrysO����!�!�	D��O�1�	D��'�'��(:�;�;�	D�

�O�*�*�5�<���C�C�C� )�+�*:� ;� ;���t�|�+�+��O�*�*�5�<���C�C�C�*5��
�&�'�!%�����%��O�$�$��)�$�$�!%��!9�K���
�
���
�
�����!���!�[�����1�$�$��O�-�-�� �+�"2�D�K�
�
�
�
�
�%�$r2�
pathname_namec�`�|�|��}|jt|��S)a)Retrieves the specified child file or directory entry.

        Args:
            pathname_name: The basename of the child object to retrieve.

        Returns:
            The fake file or directory object.

        Raises:
            KeyError: if no child exists by the specified name.
        )�_normalized_entrynamer�r)r/r�s  r1�	get_entryzFakeDirectory.get_entry)s,���2�2�=�A�A�
��|�I�m�4�4�5�5r2c�Z��|jjs�fd�|jD��}|r|d��S)Nc�h��g|].}|�������k�,|��/Sr�)�lower)r�rHr�s  �r1r�z7FakeDirectory._normalized_entryname.<locals>.<listcomp>:s>�������������AT�AT�AV�AV�1V�1V��1V�1V�1Vr2r)rJ�is_case_sensitiver�)r/r��matching_namess ` r1r�z#FakeDirectory._normalized_entryname8sT�����0�	2�����!%�����N��
2� .�q� 1�
��r2T�	recursivec��|�|��}|�|��}|jj�r"t	��s=|jtjzdkr%|j�tj
|��|j�|��r�d}tj
dkr�ttd��sntjd���}t"jdkr%|dj
dkr|djd	krd
}n$|dj
dkr|djd	krd
}|r%|j�tj
|��ndt
j��sQ|�tjtjz��s%|j�tj
|��|rQt-|t.��r<|jr4|�t5|j��d��|j�4n2|jdkr'|j�|j||j��|xjdzc_|xjdzc_|jdksJ�|jt?|��=d
S)a(Removes the specified child file or directory.

        Args:
            pathname_name: Basename of the child object to remove.
            recursive: If `True` (default), the entries in contained directories
                are deleted first. Used to propagate removal errors
                (e.g. permission problems) from contained entries.

        Raises:
            KeyError: if no child exists by the specified name.
            OSError: if user lacks permission to delete the file,
                or (Windows only) the file is open.
        rT�posix�	O_TMPFILEr�)�limit)r��
�
TemporaryFilez_os.unlink(name)F�openerr�N) r�r�rJrUr r;rr�r~rr��
has_open_filer�rH�hasattr�	traceback�
extract_stackr�r��liner��PERM_EXErfr'r��remove_entry�listr>ryrxr=r)r/r�r�r��raise_error�sts      r1r	zFakeDirectory.remove_entryAsd���2�2�=�A�A�
����}�-�-���?�(�	L��9�9�
L����1C�!C�q�!H�!H���.�.�u�|�]�K�K�K���,�,�U�3�3�
P�"���7�g�%�%�g�b�+�.F�.F�%�#�0�q�9�9�9�B��'�'�1�1��q�E�J�/�9�9� "�1��
�.@� @� @�*/�K���a�5�:��1�1�b��e�j�DV�6V�6V�*/�K��P��O�2�2�5�<��O�O�O���?�$�$�
L�T�-@�-@��"�W�%5�5�.�.�
L���.�.�u�|�]�K�K�K��	X��E�=�9�9�	X��-�
;��"�"�4��
�#6�#6�q�#9�:�:�:��-�
;��
�^�q�
 �
 ��O�-�-�u�z�k�=�%�,�W�W�W��
�
���
�
�
���!�����~��"�"�"�"��L��=�1�1�2�2�2r2c�b�td�|j���D����S)zUReturn the total size of all files contained
        in this directory tree.
        c�(�g|]}|dj��S)r�)rxr�s  r1r�z&FakeDirectory.size.<locals>.<listcomp>~s��B�B�B�T�D��G�L�B�B�Br2)�sumr�r�rcs r1rxzFakeDirectory.sizeys/��
�B�B�T�\�-?�-?�-A�-A�B�B�B�C�C�Cr2rAc�V�|j�tj|j���)z-Setting the size is an error for a directory.r�rzs  r1rxzFakeDirectory.size�s ���o�,�,�U�\�4�9�E�E�Er2�
dir_objectc�0�|}|r||krdS|j}|�dS)zmReturn `True` if dir_object is a direct or indirect parent
        directory, or if both are the same object.TF)r^)r/rr�s   r1�has_parent_objectzFakeDirectory.has_parent_object�s9��(,���	!��j� � ��t��.�C��	!��ur2c����t�����dz}|jD]F}|j|���}|�d��D]}|r|dz|zdz}��G|S)Nz:
�
z  )r-r�r��split)r/�descriptionr��	item_descrr0s     �r1r�zFakeDirectory.__str__�s�����g�g�o�o�'�'�%�/���L�	C�	C�D���T�*�2�2�4�4�I�!����-�-�
C�
C���C�"-��"4�t�";�d�"B�K��
C��r2r�)T)r3r4r5r6r�PERM_DEFr7r�rr.r
r�r�r�rr&r�rr�r��AnyFiler�r�r	rxr�rr�r8r9s@r1r'r'�s@�������6�6�
!�)�15�	/�/��/��/��-�.�	/�/�/�/�&F�F�V�F�x��}�F�PT�F�F�F�F����c�8�m�,�����X���
�d�3�i�
�
�
��X�
� �X� �$� � � � �D
6�s�
6�w�
6�
6�
6�
6��3��3�����63�63�#�63�$�63�$�63�63�63�63�p�D�c�D�D�D��X�D�
�[�F�C�F�D�F�F�F��[�F��O������������������r2r'c
���eZdZdZ	ddedddedeef�fd�
Zed	e	e
effd
���Zed	e
f�fd���Zejde
d	dfd
���Z�xZS)�FakeDirectoryFromRealDirectoryz~Represents a fake directory copied from the real file system.

    The contents of the directory are read on demand only.
    N�source_pathrJr!�	read_only�target_pathc���|p|}tj|��}t���t	tj�|��d��|j|���|j|_|j	|_	|j
|_
|j|_|j|_||_
||_d|_dS)ao
        Args:
            source_path: Full directory path.
            filesystem: The fake filesystem where the directory is created.
            read_only: If set, all files under the directory are treated
                as read-only, e.g. a write access raises an exception;
                otherwise, writing to the files changes the fake files
                only as usually.
            target_path: If given, the target path of the directory,
                otherwise the target is the same as `source_path`.

        Raises:
            OSError: if the directory does not exist in the real file system
        r�)rHr�rJFN)r�r�r-r.rr�rr;rDrBrCr@r?rrr�)r/rrJrr�	real_statr0s      �r1r.z'FakeDirectoryFromRealDirectory.__init__�s����*"�0�[���G�K�(�(�	�
������2�7�=�=��5�5�a�8�9�9��'�!�	�	
�	
�	
�"�*��
�!�*��
�!�*��
��&����&���&���"���"����r2r+c�<�|j�sd|_|j}tj|j��D]�}tj�|j|��}tj�||��}tj�|��r|j�||����tj�	|��r#|j�
||j|�����|j�||j|�����|j
S)z[Return the list of contained directory entries, loading them
        if not already loaded.T)r)r�r�r��listdirrr��islinkrJ�add_real_symlink�isdir�add_real_directoryr�
add_real_filer�)r/�baser�rrs     r1r�z&FakeDirectoryFromRealDirectory.entries�s���!�	�!%�D���9�D���D�$4�5�5�
�
�� �g�l�l�4�+;�U�C�C�� �g�l�l�4��7�7���7�>�>�+�.�.�	��O�4�4�[�+�N�N�N�N��W�]�]�;�/�/���O�6�6�#�T�^��7������O�1�1�#�T�^��2������}�r2c�<��|jsdSt��jSr})r�r-rx)r/r0s �r1rxz#FakeDirectoryFromRealDirectory.size�s!����!�	��1��w�w�|�r2rAc�V�|j�tj|j���r�r�rzs  r1rxz#FakeDirectoryFromRealDirectory.size�s���o�,�,�U�\�4�9�E�E�Er2r�)r3r4r5r6rr�rr.r�rr7r&r�r�rxr�r8r9s@r1rr�s���������*.�$#�$#��$#�%�$#��	$#�
�g�&�$#�$#�$#�$#�$#�$#�L���c�8�m�,�����X��*��c�������X��
�[�F�C�F�D�F�F�F��[�F�F�F�F�Fr2rc��eZdZdZ	d@dedededededd	d
ee	deded
ee	dee	de
dededefd�ZdAd�Zdee
edeedeeddfd�Zde	defd�Zdefd�Zde
fd�ZdBd�Zd ee
ddfd!�Zedefd"���Zede	fd#���Zd$e
ddfd%�ZdBd&�ZdBd'�ZdBd(�ZdCd*e
d+e
ddfd,�Zde
fd-�ZdBd.�Z d/e!ddfd0�Z"d1e	de#fd2�Z$d1e	de#fd3�Z%d1e	de#fd4�Z&d5e
ddfd6�Z'de#fd7�Z(de
fd8�Z)d1e	de*fd9�Z+de#fd:�Z,de#fd;�Z-defd<�Z.dBd=�Z/de0e1e	e1e!ffd>�Z2d?�Z3dS)Dr"z�Wrapper for a stream object for use by a FakeFile object.

    If the wrapper has any data written to it, it will propagate to
    the FakeFile object on close() or flush().
    F�file_objectr*rN�allow_update�delete_on_closerJr!�newline�binary�closefdrKrL�	buffering�raw_io�opened_as_fd�	is_streamc�d�||_||_||_||_|	|_|j|_|
|_||_||_	||_
d|_||_|jdkr|std���|jdks|stj|_|o|dk|_|j}|
p
t%��|_|pd}|rt)|��nt+||
||���|_d|_d|_d|_|rt5|��|_|jrd|jjs|j�d��n=|j�|j��|j���|_|r|s
Jd���||_||_|j |_!d|_"dS)	NFrzcan't have unbuffered text I/O���r�rQ)rKr0rLz(delete_on_close=True requires filesystem)#r-r*rNr.�_closefdr]�_file_epochr4�_binaryr5r6�_changed�_buffer_sizerS�io�DEFAULT_BUFFER_SIZE�_use_line_bufferrdr�	_encodingrr�_io�_read_whence�
_read_seek�
_flush_posr\�append�seek�tell�_filesystemr/r`rH�filedes)r/r-r*rNr.r/rJr0r1r2rKrLr3r4r5r6rIs                 r1r.zFakeFileWrapper.__init__�s���$'���"���$���(�����
�&�,���������(���"�����
�%������!�!�&�!��=�>�>�>�
�
�"�
$�
$�F�
$� "� 6�D��$*�
� =�y�A�~����,��!�:�%8�%:�%:����#�8���
�N�8�$�$�$���8�W�V����	
������������	6�!�(�m�m�D�O�� �
6���-�6��H�M�M�!�$�$�$�$��H�M�M�$�/�2�2�2�&*�h�m�m�o�o�D�O��	J��I�I�I�I�I�:�%���.��� �)��	�&*����r2r+c��|S)�=To support usage of this fake file with the 'with' statement.r�rcs r1�	__enter__zFakeFileWrapper.__enter__2����r2�exc_type�exc_val�exc_tbNc�.�|���dS)rLN��close�r/rOrPrQs    r1�__exit__zFakeFileWrapper.__exit__6���	
�
�
�����r2�messagec��|jr*|j�tj|j��t
j|���r�)r4rIr~r�EBADFr*r>�UnsupportedOperation)r/rXs  r1�_raisezFakeFileWrapper._raise?s;���;�	I���+�+�E�K���H�H�H��%�g�.�.�.r2c��|jS)zTReturn the FakeFile object that is wrapped
        by the current instance.
        �r-rcs r1�
get_objectzFakeFileWrapper.get_objectDs
����r2c�j�|j�|jS|j�tj��dS)�.Return the file descriptor of the file object.N)rJrIr~rrZrcs r1�filenozFakeFileWrapper.filenoJs1���<�#��<����'�'���4�4�4�4�4r2c�:�|�|j��dS)zClose the file.N��close_fdrJrcs r1rTzFakeFileWrapper.closeP����
�
�d�l�#�#�#�#�#r2�fdc��|���sdS|js�	|���nP#t$rC}|jtjkr(|jsJ�|j�|j���d}~wwxYw|jj	r$|j
rtj��|j
_|�J�|jr|j�|��n+|jj|}|�J�|�|��|jr3|j�|���j��dSdS)z-Close the file for the given file descriptor.N)�_is_openr4�flush�OSErrorrrZrJrI�close_open_filerUr<rrXr-rCr9�
open_files�remover/�
remove_objectr_r�)r/rg�erms    r1rezFakeFileWrapper.close_fdTsc���}�}���	��F��{�	:�
��
�
�������
�
�
��7�e�k�)�)� �<�'�'�<��$�4�4�T�\�B�B�B������

������-�
:�$�-�
:�,3�K�M�M�� �)��~�~�~��=�	$���,�,�R�0�0�0�0��)�4�R�8�J��)�)�)����d�#�#�#���	���*�*����!�!�&�
�
�
�
�
�	�	s�4�
B�>A<�<Bc�,�|���S)z(Simulate the `closed` attribute on file.)rircs r1�closedzFakeFileWrapper.closedvs���=�=�?�?�"�"r2c�L�|jjr|jrdnd}|jjr|dzn|S|jjr'|jr|jjrdndS|jjrdndS|jjr|jrdnd	}|jjr|dzn|S|jrd
nd}|jjr|dzn|S)N�ab�a�+zrb+�wbzw+�w�xb�xr��r)rNrFr;�can_read�truncate�must_not_exist�	can_write)r/�ms  r1�modezFakeFileWrapper.mode{s����?�!�	>���-���#�A�"�o�6�=�1�s�7�7�A�=��?�#�	=��|�
C� $�� 8�B�u�u�d�B��?�3�<�4�4��<��?�)�	>���-���#�A�"�o�6�=�1�s�7�7�A�=��L�)�D�D�c���/�3�:�q�3�w�w��:r2�old_posc���|j}	|���dS#t$r<|j�|��|j���||_�wxYw)z0Try to flush and reset the position if it fails.N)rErjrkrBrGr})r/r��	flush_poss   r1�
_try_flushzFakeFileWrapper._try_flush�sl���O�	�	��J�J�L�L�L�L�L���	�	�	��H�M�M�'�"�"�"��H������'�D�O��	���s
��AA%c��|jrdS|���|j�r?|jjre|j���}|���|jj	}|�J�|||j
d�z}|�|��n2|j���|j���}|j�
||j��}|���|r?|jjrd|_n+t'j��}||j_||j_|jj|_|���dSt5|j�����}d}|jj	�t5|jj	��}||kr&|j�t8j��dSdS)zFlush file contents to 'disk'.NTr)r6�_check_open_filer.rNrFrB�getvalue�_sync_ior-rdrE�_set_stream_contentsrjr�rA�update_flush_posrIrUr<rrXrDrCr]r:�_flush_related_filesr\r~rrZ)r/rI�old_contentsr��current_time�
buf_length�content_lengths       r1rjzFakeFileWrapper.flush�s����>�	��F���������	=���%�	
/��8�,�,�.�.���
�
����#�/�=��#�/�/�/�'�(�4�?�3D�3D�*E�E���)�)�(�3�3�3�3����� � � ��8�,�,�.�.���&�3�3�H�d�n�M�M�G��!�!�#�#�#��
=��#�1�=�$(�D�M�M�#*�;�=�=�L�0<�D�$�-�0<�D�$�-�#�/�5�D���%�%�'�'�'�'�'��T�X�.�.�0�0�1�1�J��N���-�9�!$�T�%5�%C�!D�!D����+�+�� �/�/���<�<�<�<�<�,�+r2c�B�|j���|_dSr�)rBrHrErcs r1r�z FakeFileWrapper.update_flush_pos�s���(�-�-�/�/����r2c���|jjdd�D]R}|�N|D]K}||urEt|t��r0|j|jkr |jjs|����L�SdS�Nr�)rIrmrfr"r-rNrFr�)r/rm�	open_files   r1r�z$FakeFileWrapper._flush_related_files�s����*�5�a�b�b�9�		-�		-�J��%�!+�-�-�I�!��-�-�&�y�/�B�B�.� �,�	�0E�E�E� )� 4� ;�F�"�*�*�,�,�,���		-�		-r2r�offset�whencec���|���|jjs|j�||��n||_||_|js|���dSdS)z"Move read/write pointer in 'file'.N)	r�rNrFrBrGrDrCr6rj)r/r�r�s   r1rGzFakeFileWrapper.seek�sn����������%�	'��H�M�M�&�&�)�)�)�)�$�D�O� &�D���~�	��J�J�L�L�L�L�L�	�	r2c��|���|js|���|jjs|j���S|jr}|j���}|j�|j	|j��|j���|_	d|_|j�|��|j	S)zoReturn the file's current position.

        Returns:
          int, file's current position in bytes.
        r)
r�r6rjrNrFrBrHrCrGrD)r/�
write_seeks  r1rHzFakeFileWrapper.tell�s���	
�������~�	��J�J�L�L�L���%�	#��8�=�=�?�?�"���	&�������J��H�M�M�$�/�4�+<�=�=�=�"�h�m�m�o�o�D�O� !�D���H�M�M�*�%�%�%���r2c��|j|jjkrdS|jj}|�J�|�|��|jj|_dS)z;Update the stream with changes to the file object contents.N)r:r-r]rdr�r�s  r1r�zFakeFileWrapper._sync_io�sZ����t�/�5�5�5��F��#�1���#�#�#��!�!�(�+�+�+��+�1����r2rIc�"�|j���}|j�d��|j���|j�|��|jjs|j�|��dSdSr})rBrHrGr}�putvaluerNrF)r/rIr�s   r1r�z$FakeFileWrapper._set_stream_contents�s������������
�
�a���������������(�#�#�#���%�	"��H�M�M�&�!�!�!�!�!�	"�	"r2rHc�@���t�j|�����fd�}|S)a_Wrap a stream attribute in a read wrapper.

        Returns a read_wrapper which tracks our own read pointer since the
        stream object has no concept of a different read and write pointer.

        Args:
            name: The name of the attribute to wrap. Should be a read call.

        Returns:
            The read_wrapper function.
        c�����j��j�j���|i|��}�j����_d�_�j�dd��|S)a�Wrap all read calls to the stream object.

            We do this to track the read pointer separate from the write
            pointer.  Anything that wants to read from the stream object
            while we're in append mode goes through this.

            Args:
                *args: pass through args
                **kwargs: pass through kwargs
            Returns:
                Wrapped stream object method
            r�)rBrGrDrCrH)�args�kwargs�	ret_value�io_attrr/s   ��r1�read_wrapperz4FakeFileWrapper._read_wrappers.<locals>.read_wrapper
si���
�H�M�M�$�/�4�+<�=�=�=����0��0�0�I�"�h�m�m�o�o�D�O� !�D���H�M�M�!�Q�����r2�r�rB)r/rHr�r�s`  @r1�_read_wrapperszFakeFileWrapper._read_wrappers�s=�����$�(�D�)�)��	�	�	�	�	�	�(�r2c�@���t�j|�����fd�}|S)z�Wrap a stream attribute in an other_wrapper.

        Args:
          name: the name of the stream attribute to wrap.

        Returns:
          other_wrapper which is described below.
        c�����j���}�|i|��}|�j���kr%�j����_d�_|S)�Wrap all other calls to the stream Object.

            We do this to track changes to the write pointer.  Anything that
            moves the write pointer in a file open for appending should move
            the read pointer as well.

            Args:
                *args: Pass through args.
                **kwargs: Pass through kwargs.

            Returns:
                Wrapped stream object method.
            r)rBrHrDrC)r�r�r�r�r�r/s    ��r1�
other_wrapperz5FakeFileWrapper._other_wrapper.<locals>.other_wrapper+s\���������J����0��0�0�I��T�X�]�]�_�_�,�,�"&�(�-�-�/�/���$%��!��r2r�)r/rHr�r�s`  @r1�_other_wrapperzFakeFileWrapper._other_wrapper s=�����$�(�D�)�)��	�	�	�	�	�	�,�r2c�@���t�j|�����fd�}|S)z�Wrap a stream attribute in a write_wrapper.

        Args:
          name: the name of the stream attribute to wrap.

        Returns:
          write_wrapper which is described below.
        c�����j���}�|i|��}�j���}�jo	d|dv}|�jz
�jks|rd||z
�jkp|}|s3�j�|���j�����|��|s�|i|��}�jj	r%�j����_
d�_|S)r�rr)rBrHr@rEr=rGr}r�rNrFrDrC)	r�r�r�r��new_pos�use_line_buf�	flush_allr�r/s	       ��r1�
write_wrapperz5FakeFileWrapper._write_wrapper.<locals>.write_wrapperNs����h�m�m�o�o�G����0��0�0�I��h�m�m�o�o�G� �0�D�T�T�!�W�_�L����(�4�+<�<�<��<�#�g�-��0A�A�Q�\�	�!�(��H�M�M�'�*�*�*��H�%�%�'�'�'�����(�(�(� �9� '��� 8�� 8� 8�I���%�
&�"&�(�-�-�/�/���$%��!��r2r�)r/rHr�r�s`  @r1�_write_wrapperzFakeFileWrapper._write_wrapperCs>�����$�(�D�)�)��"	�"	�"	�"	�"	�"	�H�r2rxc���|jjdd�D]a}|�]|D]Z}||urTt|t��r?|j|jkr/tt|��jjr|xj|z
c_�[�bdSr�)	rIrmrfr"r-rrNrFrD)r/rxrmr�s    r1�_adapt_size_for_related_filesz-FakeFileWrapper._adapt_size_for_related_filests����*�5�a�b�b�9�		5�		5�J��%�!+�5�5�I�!��-�-�&�y�/�B�B�.� �,�	�0E�E�E� ��)�<�<�G�N�F�"�,�,��4�,�,���		5�		5r2c�.����jj���fd�}|S)zwWrap truncate() to allow flush after truncate.

        Returns:
            Wrapper which is described below.
        c�h���jjr%�j��j�j���|i|��}�����js�|�j_	t�j�����}||kr��j�|���j�d||z
z���j�
�j����j��|�_��||z
������|S)z0Wrap truncate call to call flush after truncate.r�)rNrFrBrGrDrCrjr6r-rxr\r�r�r�rArEr�)r�r�rx�buffer_sizer�r/s    ��r1�truncate_wrapperz;FakeFileWrapper._truncate_wrapper.<locals>.truncate_wrapper�s�����%�
B���
�
�d�o�t�/@�A�A�A��7�D�+�F�+�+�D��J�J�L�L�L��>�
K�(,�� �%�!�$�(�"3�"3�"5�"5�6�6����%�%��H�M�M�+�.�.�.��H�%�%�e�t�k�/A�&B�C�C�C��$�1�1�$�(�2C�2C�2E�2E�t�~�V�V�V�&*�D�O��6�6�t�k�7I�J�J�J��J�J�L�L�L��Kr2)rBr})r/r�r�s` @r1�_truncate_wrapperz!FakeFileWrapper._truncate_wrapper�s6�����(�#��	�	�	�	�	�	�& �r2c��|jjS)z5Return the content size in bytes of the wrapped file.)r-rArcs r1rxzFakeFileWrapper.size�s����'�'r2c�4�|j���rt|j���|�d��p|dk}|dk}|�d��p|}|s|r|���|jjs|r|���S|j	s|j
s|r|���S|rX|���|j
s|���|jjst#j��|j_|r|���S|jjr.|r|�|��S|s|�|��S|r|�|��St3|j|��S)Nr��nextr}�write)r-r�r)r*�
startswithr�rNr|�_read_errorr5r.�_write_errorr�r6rjrIrUrrXrBr�rFr�r�r�r�rB)r/rH�readingr}�writings     r1r�zFakeFileWrapper.__getattr__�s�����)�)�+�+�	;�*�4�>�:�:�:��/�/�&�)�)�;�T�V�^���:�%���/�/�'�*�*�6�h���	$�g�	$��!�!�#�#�#���'�	&�G�	&��#�#�%�%�%�� �	'��):�	'�w�	'��$�$�&�&�&��	:��M�M�O�O�O��>�
��
�
�����#�1�
:�,3�K�M�M�� �)��	,��)�)�+�+�+��?�!�	1��
1��*�*�4�0�0�0��
1��*�*�4�0�0�0��	-��&�&�t�,�,�,��t�x��&�&�&r2c����fd�}|S)Nc���|r*|ddkr�jjr�jr�jrdndS��d��dS)z+Throw an error unless the argument is zero.rr2rRzFile is not open for reading.N)rIrUr4r;r\�r�r�r/s  �r1�
read_errorz/FakeFileWrapper._read_error.<locals>.read_error�sX����
7��Q��1����#�1�7�d�k�7�"&�,�6�3�3�B�6��K�K�7�8�8�8�8�8r2r�)r/r�s` r1r�zFakeFileWrapper._read_error�s$���	9�	9�	9�	9�	9��r2c����fd�}|S)Nc����jr)�jjr|rt|d��dkrdS��d��dS)zThrow an error.rzFile is not open for writing.N)r4rIrUr\r\r�s  �r1�write_errorz1FakeFileWrapper._write_error.<locals>.write_error�sT����{�
��#�1��d��s�4��7�|�|�q�?P�?P��1��K�K�7�8�8�8�8�8r2r�)r/r�s` r1r�zFakeFileWrapper._write_error�s$���	9�	9�	9�	9�	9��r2c��|j�A|jt|jj��kr|jj|j}|�||vrdSdS)NTF)rJr\rIrm)r/rms  r1rizFakeFileWrapper._is_open�sP���<�#���s�4�;K�;V�7W�7W�(W�(W��)�4�T�\�B�J��%�$�*�*<�*<��t��ur2c�^�|js#|���std���dSdS)NzI/O operation on closed file)r6rirSrcs r1r�z FakeFileWrapper._check_open_file�s>���~�	=�d�m�m�o�o�	=��;�<�<�<�	=�	=�	=�	=r2c�v�|jjs|�d��|j���S�NzFile is not open for reading)rNr|r\rB�__iter__rcs r1r�zFakeFileWrapper.__iter__�s6����'�	8��K�K�6�7�7�7��x� � �"�"�"r2c�l�|jjs|�d��t|j��Sr�)rNr|r\r�rBrcs r1�__next__zFakeFileWrapper.__next__�s0����'�	8��K�K�6�7�7�7��D�H�~�~�r2)F)r+r"�r+Nr�)4r3r4r5r6r&r
rr�rr7r�r.rMr�
BaseExceptionrrVrr\r_rbrTrer�rrr�r�rjr�r�rGrHr�rgr�rr�r�r�r�r�rxr
r�r�r�rir�r	rr�r�r�r2r1r"r"�s���������, �!B+�B+��B+��B+��	B+�
�B+��
B+�%�B+��#��B+��B+��B+��3�-�B+���
�B+��B+��B+��B+� �!B+�B+�B+�B+�H������4�
�.�/���-�(����'�	�

�����/�c�/�h�/�/�/�/�
 �H� � � � �5��5�5�5�5�$�$�$�$� �8�C�=� �T� � � � �D�#��#�#�#��X�#��;�c�;�;�;��X�;�
�#�
�$�
�
�
�
�$=�$=�$=�$=�L*�*�*�*�
-�
-�
-�
-�	�	�3�	��	�D�	�	�	�	��c�����(2�2�2�2�"�U�"�t�"�"�"�"�"�3�"�8�"�"�"�"�H!�3�!�8�!�!�!�!�F/�3�/�8�/�/�/�/�b
5�#�
5�$�
5�
5�
5�
5� �8� � � � �:(�c�(�(�(�(�'��'��'�'�'�'�B�X������h������$�����=�=�=�=�#�%���
�x��� >�?�#�#�#�#�
����r2r"c���eZdZdZdefd�Zdefd�Zdefd�Zddede	fd	�Z
d
e	defd�Zdd
�Zde
eddfd�Zdefd�Zdd�Zde
eede
ede
eddfd�ZdS)r$zCWrapper for a system standard stream to be used in open files list.�
stream_objectc�"�||_d|_dSr�)�_stream_objectrJ)r/r�s  r1r.zStandardStreamWrapper.__init__�s��+���&*����r2r+c��|jSr�)r�rcs r1r_z StandardStreamWrapper.get_object�s���"�"r2c��|j�|jSttjt	jtj�����)z:Return the file descriptor of the wrapped standard stream.�rJrkrrZr��strerrorrcs r1rbzStandardStreamWrapper.fileno��0���<�#��<���e�k�2�;�u�{�#;�#;�<�<�<r2r8�nc�Z�tt|j�����Sr�)rrgr�r�)r/r�s  r1r�zStandardStreamWrapper.read�s!���E�4�.�3�3�5�5�6�6�6r2rIc�z�|j�tt|����t	|��Sr�)r�r�rr7r\r�s  r1r�zStandardStreamWrapper.write�s/����!�!�$�s�H�"5�"5�6�6�6��8�}�}�r2Nc��dS�z+We do not support closing standard streams.Nr�rcs r1rTzStandardStreamWrapper.close����r2rgc��dSr�r��r/rgs  r1rezStandardStreamWrapper.close_fdr�r2c��dSr�r�rcs r1r6zStandardStreamWrapper.is_stream	s���tr2c��|S)�CTo support usage of this standard stream with the 'with' statement.r�rcs r1rMzStandardStreamWrapper.__enter__rNr2rOrPrQc�.�|���dS)r�NrSrUs    r1rVzStandardStreamWrapper.__exit__rWr2�r8r�)r+r$)r3r4r5r6rr.r_r�rbrgr�r�rTrrer�r6rMrr�rrVr�r2r1r$r$�sk������M�M�+�f�+�+�+�+�#�F�#�#�#�#�=��=�=�=�=�7�7�c�7�5�7�7�7�7��e�������:�:�:�:�:�8�C�=�:�T�:�:�:�:��4�����������4�
�.�/���-�(����'�	�

������r2r$c���eZdZdZdededdfd�Zdefd�Zdefd	�Z	dd�Z
deedd
fd
�Zddede
fd�Zde
defd�Zdd�Zdeeedeedeedd
fd�Zd
S)r#zAWrapper for a FakeDirectory object to be used in open files list.r-r*rJr!c�>�||_||_||_d|_dSr�)r-r*rIrJ)r/r-r*rJs    r1r.zFakeDirWrapper.__init__s&��'���"���%���&*����r2r+c��|jS)zKReturn the FakeFile object that is wrapped by the current
        instance.r^rcs r1r_zFakeDirWrapper.get_object(s
����r2c��|j�|jSttjt	jtj�����)rar�rcs r1rbzFakeDirWrapper.fileno-r�r2Nc�:�|�|j��dS�zClose the directory.Nrdrcs r1rTzFakeDirWrapper.close3rfr2rgc�B�|�J�|j�|��dSr�)rIrlr�s  r1rezFakeDirWrapper.close_fd7s(���~�~�~���(�(��,�,�,�,�,r2r8�numBytesc�6�|j�|��S)zRead from the directory.)r-r��r/r�s  r1r�zFakeDirWrapper.read<s����$�$�X�.�.�.r2rIc�T�|j�|��t|��S)zWrite to the directory.)r-r�r\r�s  r1r�zFakeDirWrapper.write@s%������x�(�(�(��8�}�}�r2c��|S)�BTo support usage of this fake directory with the 'with' statement.r�rcs r1rMzFakeDirWrapper.__enter__ErNr2rOrPrQc�.�|���dS)r�NrSrUs    r1rVzFakeDirWrapper.__exit__IrWr2r�r�)r+r#)r3r4r5r6r'rr.r_r�rbrTrrergr�r�rMrr�rrVr�r2r1r#r#se������K�K�	+�"�	+��	+�%�		+�	+�	+�	+� �M� � � � �
=��=�=�=�=�$�$�$�$�-�8�C�=�-�T�-�-�-�-�
/�/�S�/�%�/�/�/�/��e�������
������4�
�.�/���-�(����'�	�

������r2r#c	��eZdZdZ	ddddededefd�Zdd
�Zde	e
ede	ed
e	ed	dfd�Z
dd�Zd	efd�Zd ded	efd�Zdd�Zded	efd�Zdd�Zde	ed	dfd�Zd	efd�Zd	efd�Zd	efd�ZdS)!r%zdWrapper for a read or write descriptor of a real pipe object to be
    used in open files list.
    rRrJr!rgrr�c��||_||_||_d|_d|_d|_|rt
||��|_dSdSr�)rIrgrr-rJ�	real_file�open)r/rJrgrr�s     r1r.zFakePipeWrapper.__init__XsU��&������"������&*�������	,�!�"�d�^�^�D�N�N�N�	,�	,r2r+c��|S)�=To support usage of this fake pipe with the 'with' statement.r�rcs r1rMzFakePipeWrapper.__enter__hrNr2rOrPrQNc�.�|���dS)r�NrSrUs    r1rVzFakePipeWrapper.__exit__lrWr2c��|jSr�r^rcs r1r_zFakePipeWrapper.get_objectus����r2c��|j�|jSttjt	jtj�����)z3Return the fake file descriptor of the pipe object.r�rcs r1rbzFakePipeWrapper.filenoxr�r2r8r�c�x�|jr|j�|��Stj|j|��S)zRead from the real pipe.)r�r�r�rgr�s  r1r�zFakePipeWrapper.read~s6���>�	1��>�&�&�x�0�0�0��w�t�w��)�)�)r2c��dS)zFlush the real pipe?Nr�rcs r1rjzFakePipeWrapper.flush�r�r2rIc�x�|jr|j�|��Stj|j|��S)zWrite to the real pipe.)r�r�r�rgr�s  r1r�zFakePipeWrapper.write�s6���>�	2��>�'�'��1�1�1��x����*�*�*r2c�:�|�|j��dS)zClose the pipe descriptor.Nrdrcs r1rTzFakePipeWrapper.close�rfr2c���|�J�|jj|}|�J�|�|��|jr|j���dStj|j��dS)z9Close the pipe descriptor with the given file descriptor.N)rIrmrnr�rTr�rg)r/rgrms   r1rezFakePipeWrapper.close_fd�sw���~�~�~��%�0��4�
��%�%�%����$�����>�	��N� � �"�"�"�"�"��H�T�W�����r2c��|jS�z0The pipe end can either be readable or writable.�rrcs r1�readablezFakePipeWrapper.readable�s
���>�!�!r2c��|jSrrrcs r1�writablezFakePipeWrapper.writable�s
���~�r2c��dS)zA pipe is not seekable.Fr�rcs r1�seekablezFakePipeWrapper.seekable�r�r2)rR)r+r%r�r�)r3r4r5r6r�r�r7r.rMrrr�rrVr_rbrgr�rjr�rTrerr
rr�r2r1r%r%Ss����������,�,�$�,�
�,��	,�
�,�,�,�,� ������4�
�.�/���-�(����'�	�

����� � � � �=��=�=�=�=�*�*�S�*�%�*�*�*�*�#�#�#�#�+�e�+��+�+�+�+�$�$�$�$�	�8�C�=�	�T�	�	�	�	�"�$�"�"�"�"��$������$������r2r%):r6rr>r�r�rr�rr�typesr�typingrrrr	r
rrr
rrrrr�pyfakefsr�pyfakefs.helpersrrrrrrrrrrrrr �pyfakefs.fake_filesystemr!r�r��AnyFileWrapperr�	Exceptionr)r&r�r�r'rr"r$r#r%r�r2r1�<module>rs���7�6�����	�	�	�	�	�	�	�	�
�
�
�
������������� ������������������������������������ ������������������������������������ �8�7�7�7�7�7�7�
�'�������+�
,��	
�	
�	
�	
�	
�y�	
�	
�	
�IM�IM�IM�IM�IM�IM�IM�IM�X
	�	�	�	�	�8�	�	�	�,�,�,�,�,�8�,�,�,�^w�w�w�w�w�H�w�w�w�tKF�KF�KF�KF�KF�]�KF�KF�KF�\B�B�B�B�B�B�B�B�J+�+�+�+�+�+�+�+�\6�6�6�6�6�6�6�6�rS�S�S�S�S�S�S�S�S�Sr2