§
    Uä�a>2  ã                   ó`  — d dl mZ d dl mZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ  G d„ de	¦  «        Z G d„ dee¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )é    )Úabsolute_import)Úprint_functionN)ÚBytesIO)ÚDEFAULT_BUFFER_SIZE)ÚFileIO)Ú	RawIOBase)ÚUnsupportedOperation)Úreraise)Úcancel_wait_ex)ÚFileObjectBase)ÚOpenDescriptor)ÚWriteIsWriteallMixin)Úwait_on_watcher)Úget_hub)Ú_read)Ú_write)Úignored_errors)Úmake_nonblockingc                   ó¦   — e Zd ZdZdZdZdZdZdd„Zd„ Z	d„ Z
d„ Zd„ Zd	„ Zed
„ ¦   «         Zd„ Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ ZdS )ÚGreenFileDescriptorIONFTc                 óx  — t          j        | ¦  «         || _        || _        || _        |j        | _        t          |¦  «         |j        }|j	        }t          ¦   «         | _        | j        j        j        }	 |r ||d¦  «        | _        |r ||d¦  «        | _        d S d S #  |                      ¦   «          ‚ xY w)Né   é   )r   Ú__init__Ú_closefdÚ_filenoÚnameÚfileio_modeÚmoder   Úcan_readÚ	can_writer   ÚhubÚloopÚioÚ_read_watcherÚ_write_watcherÚclose)ÚselfÚfilenoÚopen_descriptorÚclosefdÚreadableÚwritableÚ
io_watchers          ú9/usr/lib/python3/dist-packages/gevent/_fileobjectposix.pyr   zGreenFileDescriptorIO.__init__)   sÏ   € ÝÔ˜4Ñ Ô Ð àˆŒØˆŒØˆŒ	Ø#Ô/ˆŒ	Ý˜Ñ Ô Ð Ø"Ô+ˆØ"Ô,ˆå‘9”9ˆŒØ”X”]Ô%ˆ
ð	Øð ;Ø%/ Z°¸Ñ%:Ô%:�Ô"àð <Ø&0 j°¸Ñ&;Ô&;�Ô#Ð#Ð#ð<ð <øð	ð �JŠJ‰LŒLˆLØøøøs   Á8&B" Â"B9c                 ó²   — t          | j        dd¦  «        }	 |                     ¦   «         |                     ¦   «          S # |                     ¦   «          w xY w)NÚrF)r   r   Úisattyr'   )r(   Úfs     r/   r2   zGreenFileDescriptorIO.isattyM   sF   € å�4”<  eÑ,Ô,ˆð	Ø—8’8‘:”:à�GŠG‰IŒIˆIˆIøˆA�GŠG‰IŒIˆIˆIøøøs   ˜A  Á Ac                 ó   — | j         d uS ©N)r%   ©r(   s    r/   r,   zGreenFileDescriptorIO.readableU   s   € ØÔ!¨Ð-Ð-ó    c                 ó   — | j         d uS r5   )r&   r6   s    r/   r-   zGreenFileDescriptorIO.writableX   s   € ØÔ"¨$Ð.Ð.r7   c                 ó¨   — | j         €E	 t          j        | j        dt          j        ¦  «         d| _         n# t
          $ r
 d| _         Y nw xY w| j         S )Nr   TF)Ú	_seekableÚosÚlseekr   ÚSEEK_CURÚOSErrorr6   s    r/   ÚseekablezGreenFileDescriptorIO.seekable[   sd   € ØŒ>Ð!ð&Ý”˜œ q­"¬+Ñ6Ô6Ð6ð "&�”�øõ ð 'ð 'ð 'Ø!&�”��ð'øøøð Œ~Ðs   ‰%6 ¶A
Á	A
c                 ó   — | j         S r5   )r   r6   s    r/   r)   zGreenFileDescriptorIO.filenoe   s
   € ØŒ|Ðr7   c                 ó   — | j         S r5   )Ú_closedr6   s    r/   ÚclosedzGreenFileDescriptorIO.closedh   s
   € àŒ|Ðr7   c                 óÄ   — | j         }| j        }| j        }d x| _        x| _         | _        |                     ||ft          | j        | j        | j        | j        ¦  «         d S r5   )	r%   r&   r"   Úcancel_waits_close_and_thenr   Ú$_GreenFileDescriptorIO__finish_closer   r   Ú_keep_alive)r(   Ú
read_eventÚwrite_eventr"   s       r/   Ú__destroy_eventsz&GreenFileDescriptorIO.__destroy_eventsl   ss   € ØÔ'ˆ
ØÔ)ˆØŒhˆØ>BÐBˆŒÐB�4Ô%¨Ô(;à×'Ò'Ø˜Ð%ÝØÔØŒMØŒLØÔñ	
ô 	
ð 	
ð 	
ð 	
r7   c                 óº   — | j         rd S |                      ¦   «          d| _         	 |                      ¦   «          d x| _        | _        d S # d x| _        | _        w xY w)NT)rB   ÚflushÚ&_GreenFileDescriptorIO__destroy_eventsr   rG   r6   s    r/   r'   zGreenFileDescriptorIO.close{   sn   € ØŒ<ð 	ØˆFØ�
Š
‰Œˆð ˆŒð	3Ø×!Ò!Ñ#Ô#Ð#à.2Ð2ˆDŒL˜4Ô+Ð+Ð+ø¨dÐ2ˆDŒL˜4Ô+Ð2Ð2Ð2Ð2s   ¦A
 Á
Ac                 óÔ   — 	 | rt          j        |¦  «         t          |d¦  «        r|                     ¦   «          d S d S # t          |d¦  «        r|                     ¦   «          w w xY w)Nr'   )r;   r'   Úhasattr)r+   r)   Ú
keep_alives      r/   Ú__finish_closez$GreenFileDescriptorIO.__finish_close‡   s‚   € ð	#Øð !Ý”˜Ñ Ô Ð å�z 7Ñ+Ô+ð #Ø× Ò Ñ"Ô"Ð"Ð"Ð"ð#ð #ø�w�z 7Ñ+Ô+ð #Ø× Ò Ñ"Ô"Ð"Ð"ð#øøøs   ‚A  Á 'A'c                 óü   — | j         €t          d¦  «        ‚	 	 t          | j        |¦  «        S # t          t
          f$ r}|j        d         t          vr‚ Y d }~nd }~ww xY wt          | j         d d | j	        ¦  «         Œf)NÚreadr   r   )
r%   r	   r   r   ÚIOErrorr>   Úargsr   r   r"   )r(   ÚnÚexs      r/   Ú__readzGreenFileDescriptorIO.__read—   s    € ØÔÐ%Ý& vÑ.Ô.Ð.ð	FðÝ˜Tœ\¨1Ñ-Ô-Ð-øÝ�WÐ%ð ð ð Ø”7˜1”:¥^Ð3Ð3Øð 4Ð3Ð3Ð3Ð3øøøøðøøøõ ˜DÔ.°°d¸D¼HÑEÔEÐEð	Fó   ™. ®A¿AÁAc                 óÖ   — t          ¦   «         }	 	 |                      t          ¦  «        }n# t          $ r d }Y nw xY w|sn|                     |¦  «         ŒG|                     ¦   «         S r5   )r   Ú_GreenFileDescriptorIO__readr   r   ÚwriteÚgetvalue)r(   ÚretÚdatas      r/   ÚreadallzGreenFileDescriptorIO.readall¢   s€   € Ý‰iŒiˆð
	ðØ—{’{Õ#6Ñ7Ô7��øÝ!ð ð ð ð ���ð	øøøð
 ð ØØ�IŠI�d‰OŒOˆOð
	ð �|Š|‰~Œ~Ðs   ‘, ¬;º;c                 ó  — |                       t          |¦  «        ¦  «        }t          |¦  «        }	 ||d |…<   nM# t          $ r@}dd l}t	          ||j        ¦  «        s|‚|                     d|¦  «        |d |…<   Y d }~nd }~ww xY w|S )Nr   ó   b)r[   ÚlenÚ	TypeErrorÚarrayÚ
isinstance)r(   Úbr_   rV   Úerrre   s         r/   ÚreadintozGreenFileDescriptorIO.readinto±   s¥   € Ø�{Š{�3˜q™6œ6Ñ"Ô"ˆÝ�‰IŒIˆð	,ØˆAˆbˆqˆb‰EˆEøÝð 	,ð 	,ð 	,ØˆLˆLˆLÝ˜a ¤Ñ-Ô-ð Ø�	Ø—K’K  dÑ+Ô+ˆAˆbˆqˆb‰EˆEˆEˆEˆEˆEøøøøð		,øøøð
 ˆs   ³; »
BÁ6B Â Bc                 óü   — | j         €t          d¦  «        ‚	 	 t          | j        |¦  «        S # t          t
          f$ r}|j        d         t          vr‚ Y d }~nd }~ww xY wt          | j         d d | j	        ¦  «         Œf)Nr\   Tr   )
r&   r	   r   r   rT   r>   rU   r   r   r"   )r(   rg   rW   s      r/   r\   zGreenFileDescriptorIO.write½   s    € ØÔÐ&Ý& wÑ/Ô/Ð/ð	GðÝ˜dœl¨AÑ.Ô.Ð.øÝ�WÐ%ð ð ð Ø”7˜1”:¥^Ð3Ð3Øð 4Ð3Ð3Ð3Ð3øøøøðøøøõ ˜DÔ/°°t¸T¼XÑFÔFÐFð	GrY   r   c                 óð   — 	 t          j        | j        ||¦  «        S # t          $ r ‚ t          $ rD}t          t          t          |j        Ž t          j        ¦   «         d         ¦  «         Y d }~d S d }~ww xY w)Nr   )	r;   r<   r   rT   r>   r
   rU   ÚsysÚexc_info)r(   ÚoffsetÚwhencerW   s       r/   ÚseekzGreenFileDescriptorIO.seekÈ   sŽ   € ð		CÝ”8˜DœL¨&°&Ñ9Ô9Ð9øÝð 	ð 	ð 	ØÝð 	Cð 	Cð 	Cõ
 •G�W b¤gÐ.µ´±´¸qÔ0AÑBÔBÐBÐBÐBÐBÐBÐBÐBøøøøð	Cøøøs   ‚ �A5±9A0Á0A5c                 óf   — dt          | ¦  «        j        t          | ¦  «        | j        | j        fz  S )Nz<%s at 0x%x fileno=%s mode=%r>)ÚtypeÚ__name__Úidr   r   r6   s    r/   Ú__repr__zGreenFileDescriptorIO.__repr__Ô   s0   € Ø/Ý�‰JŒJÔ¥ D¡¤¨4¬<¸¼ð3
ñ 
ð 	
r7   )T)r   )rs   Ú
__module__Ú__qualname__r%   r&   rB   r:   rG   r   r2   r,   r-   r?   r)   ÚpropertyrC   rM   r'   ÚstaticmethodrF   r[   r`   ri   r\   rp   ru   © r7   r/   r   r      sL  € € € € € ð €MØ€NØ€GØ€IØ€Kð"ð "ð "ð "ðHð ð ð.ð .ð .ð/ð /ð /ðð ð ðð ð ð ðð ñ „Xðð
ð 
ð 
ð
3ð 
3ð 
3ð ð#ð #ñ „\ð#ð	Fð 	Fð 	Fðð ð ð
ð 
ð 
ð	Gð 	Gð 	Gð
Cð 
Cð 
Cð 
Cð
ð 
ð 
ð 
ð 
r7   r   c                   ó   — e Zd ZdS )ÚGreenFileDescriptorIOWriteallN)rs   rv   rw   rz   r7   r/   r|   r|   Ú   s   € € € € € à€Dr7   r|   c                   ó   — e Zd Zd„ Zd„ ZdS )ÚGreenOpenDescriptorc                 ó.  — |                       ¦   «         rt          | j        | | j        ¬¦  «        }ncd}t	          j        | ¦  «        }|                     ¦   «         }t          || |¬¦  «        }||_        	 |j        |_        n# t          $ r |`Y nw xY w|S )N)r+   F)
Úis_fdr   Ú_fobjr+   r   Ú_do_open_rawr)   rG   r   ÚAttributeError)r(   Úfileior+   Úrawr)   s        r/   r‚   z GreenOpenDescriptor._do_open_rawá   s¥   € Ø�:Š:‰<Œ<ð 	 Ý*¨4¬:°tÀTÄ\ÐRÑRÔRˆFˆFð
 ˆGå Ô-¨dÑ3Ô3ˆCà—Z’Z‘\”\ˆFÝ*¨6°4ÀÐIÑIÔIˆFØ!$ˆFÔð Ø!œh�”�øÝ!ð  ð  ð  Ø�K�K�Kð øøøàˆs   Á6B ÂBÂBc                 óž   — ||us|                       |¦  «        sJ ‚|j        t          u rt          |_        nt	          j        | ||¦  «        }|S r5   )Ú_raw_object_is_newÚ	__class__r   r|   r   Ú_make_atomic_write)r(   Úresultr…   s      r/   r‰   z&GreenOpenDescriptor._make_atomic_writeö   s[   € ð ˜SÐ Ð  D×$;Ò$;¸CÑ$@Ô$@Ð Ð Ð ØÔÕ4Ð4Ð4Ý<ˆFÔÐå#Ô6°t¸VÀSÑIÔIˆFØˆr7   N)rs   rv   rw   r‚   r‰   rz   r7   r/   r~   r~   ß   s2   € € € € € ðð ð ð*	ð 	ð 	ð 	ð 	r7   r~   c                   ó"   — e Zd ZdZeZd„ Zd„ ZdS )ÚFileObjectPosixaª  
    FileObjectPosix()

    A file-like object that operates on non-blocking files but
    provides a synchronous, cooperative interface.

    .. caution::
         This object is only effective wrapping files that can be used meaningfully
         with :func:`select.select` such as sockets and pipes.

         In general, on most platforms, operations on regular files
         (e.g., ``open('a_file.txt')``) are considered non-blocking
         already, even though they can take some time to complete as
         data is copied to the kernel and flushed to disk: this time
         is relatively bounded compared to sockets or pipes, though.
         A :func:`~os.read` or :func:`~os.write` call on such a file
         will still effectively block for some small period of time.
         Therefore, wrapping this class around a regular file is
         unlikely to make IO gevent-friendly: reading or writing large
         amounts of data could still block the event loop.

         If you'll be working with regular files and doing IO in large
         chunks, you may consider using
         :class:`~gevent.fileobject.FileObjectThread` or
         :func:`~gevent.os.tp_read` and :func:`~gevent.os.tp_write` to bypass this
         concern.

    .. tip::
         Although this object provides a :meth:`fileno` method and so
         can itself be passed to :func:`fcntl.fcntl`, setting the
         :data:`os.O_NONBLOCK` flag will have no effect (reads will
         still block the greenlet, although other greenlets can run).
         However, removing that flag *will cause this object to no
         longer be cooperative* (other greenlets will no longer run).

         You can use the internal ``fileio`` attribute of this object
         (a :class:`io.RawIOBase`) to perform non-blocking byte reads.
         Note, however, that once you begin directly using this
         attribute, the results from using methods of *this* object
         are undefined, especially in text mode. (See :issue:`222`.)

    .. versionchanged:: 1.1
       Now uses the :mod:`io` package internally. Under Python 2, previously
       used the undocumented class :class:`socket._fileobject`. This provides
       better file-like semantics (and portability to Python 3).
    .. versionchanged:: 1.2a1
       Document the ``fileio`` attribute for non-blocking reads.
    .. versionchanged:: 1.2a1

        A bufsize of 0 in write mode is no longer forced to be 1.
        Instead, the underlying buffer is flushed after every write
        operation to simulate a bufsize of 0. In gevent 1.0, a
        bufsize of 0 was flushed when a newline was written, while
        in gevent 1.1 it was flushed when more than one byte was
        written. Note that this may have performance impacts.
    .. versionchanged:: 1.3a1
        On Python 2, enabling universal newlines no longer forces unicode
        IO.
    .. versionchanged:: 1.5
       The default value for *mode* was changed from ``rb`` to ``r``. This is consistent
       with :func:`open`, :func:`io.open`, and :class:`~.FileObjectThread`, which is the
       default ``FileObject`` on some platforms.
    .. versionchanged:: 1.5
       Stop forcing buffering. Previously, given a ``buffering=0`` argument,
       *buffering* would be set to 1, and ``buffering=1`` would be forced to
       the default buffer size. This was a workaround for a long-standing concurrency
       issue. Now the *buffering* argument is interpreted as intended.
    c                 óz   — t          |i |¤Ž}t          j        | |¦  «         |                     ¦   «         | _        d S r5   )r~   r   r   Ú
opened_rawr„   )r(   rU   ÚkwargsÚ
descriptors       r/   r   zFileObjectPosix.__init__J  s>   € Ý(¨$Ð9°&Ð9Ð9ˆ
ÝÔ  jÑ1Ô1Ð1à ×+Ò+Ñ-Ô-ˆŒˆˆr7   c                 óˆ   — 	 |                      ¦   «          | j                              ¦   «          d | _        d S # d | _        w xY wr5   )r'   r„   )r(   Úfobjr+   s      r/   Ú	_do_closezFileObjectPosix._do_closeP  sH   € ð	Ø�JŠJ‰LŒLˆLð ŒK×ÒÑÔÐàˆDŒKˆKˆKø˜$ˆDŒKÐÐÐÐs	   ‚-8 ¸	AN)rs   rv   rw   Ú__doc__r   Údefault_bufsizer   r“   rz   r7   r/   rŒ   rŒ     sF   € € € € € ðCð CðJ *€Oð.ð .ð .ðð ð ð ð r7   rŒ   )Ú
__future__r   r   r;   rl   r$   r   r   r   r   r	   Úgevent._compatr
   Úgevent._fileobjectcommonr   r   r   r   Úgevent._hub_primitivesr   Ú
gevent.hubr   Ú	gevent.osr   r   r   r   r   r|   r~   rŒ   rz   r7   r/   ú<module>rœ      s'  ðØ &Ð &Ð &Ð &Ð &Ð &Ø %Ð %Ð %Ð %Ð %Ð %Ø 	€	€	€	Ø 
€
€
€
ð Ð Ð Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #à "Ð "Ð "Ð "Ð "Ð "Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ø &Ð &Ð &Ð &Ð &Ð &ð}
ð }
ð }
ð }
ð }
˜Iñ }
ô }
ð }
ð@	ð 	ð 	ð 	ð 	Ð$8Ø$9ñ	ô 	ð 	ð
 ð  ð  ð  ð  ˜.ñ  ô  ð  ðFUð Uð Uð Uð U�nñ Uô Uð Uð Uð Ur7   