B
    H/\                 @   s   d Z ddlmZmZmZ ddlmZ ddlmZ G dd de	Z
e
 Z
dddZdd ZG dd de	ZG dd de	Zdd Zy(ddlmZ ddlmZ ddlmZ W n4 ek
r   G dd de	Zdd Zdd ZY nX eZeZeZdS ) z2
internal gevent utilities, not for external use.
    )print_functionabsolute_importdivision)update_wrapper)	iteritemsc               @   s   e Zd ZdZdZdd ZdS )_NONEz
    A special object you must never pass to any gevent API.
    Used as a marker object for keyword arguments that cannot have the
    builtin None (because that might be a valid value).
     c             C   s   dS )Nz<default value>r   )selfr   r   +lib/python3.7/site-packages/gevent/_util.py__repr__   s    z_NONE.__repr__N)__name__
__module____qualname____doc__	__slots__r   r   r   r   r
   r      s   r   NFr   Z__implements____all__Z__imports__Tc                s   |r0|r fdd|D }q: fdd|D }n
t  j}g }xJ|D ]B\}	}
|
tkrVqD|	|kr`qD|	drt|	|krtqD|
||	< ||	 qDW |rd|kr|d= |S )a  
    Copy attributes defined in ``source.__dict__`` to the dictionary
    in globs (which should be the caller's :func:`globals`).

    Names that start with ``__`` are ignored (unless they are in
    *dunder_names_to_keep*). Anything found in *names_to_ignore* is
    also ignored.

    If *only_names* is given, only those attributes will be
    considered. In this case, *ignore_missing_names* says whether or
    not to raise an :exc:`AttributeError` if one of those names can't
    be found.

    If *cleanup_globs* has a true value, then common things imported but
    not used at runtime are removed, including this function.

    Returns a list of the names copied; this should be assigned to ``__imports__``.
    c             3   s   | ]}|t  |tfV  qd S )N)getattrr   ).0k)sourcer   r
   	<genexpr>5   s    zcopy_globals.<locals>.<genexpr>c             3   s   | ]}|t  |fV  qd S )N)r   )r   r   )r   r   r
   r   7   s    __copy_globals)r   __dict__r   
startswithappend)r   globsZ
only_namesZignore_missing_namesZnames_to_ignoreZdunder_names_to_keepZcleanup_globsitemsZcopiedkeyvaluer   )r   r
   r      s&    
r   c          	   C   s   |  d}|r||krdS ddlm} |r.dS ddl}ddl}|  |dt ||}W dQ R X | 	  | 
|j d| kr| d= dS )zM
    Import the C-accelerator for the __name__
    and copy its globals.
    r   Nr   )PURE_PYTHONignoreimport_c_accel)getgevent._compatr!   	importlibwarningscatch_warningssimplefilterImportWarningimport_moduleclearupdater   )r   Zcnamenamer!   r&   r'   modr   r   r
   r#   L   s    

r#   c               @   s    e Zd ZdZdd Zdd ZdS )Lazyz
    A non-data descriptor used just like @property. The
    difference is the function value is assigned to the instance
    dict the first time it is accessed and then the function is never
    called agoin.
    c             C   s   ||j f| _t| | d S )N)r   datar   )r	   funcr   r   r
   __init__|   s    zLazy.__init__c             C   s,   |d kr| S | j \}}||}||j|< |S )N)r1   r   )r	   instclass_r2   r.   r    r   r   r
   __get__   s    

zLazy.__get__N)r   r   r   r   r3   r6   r   r   r   r
   r0   u   s   r0   c               @   s    e Zd ZdZdd Zdd ZdS )readpropertyz
    A non-data descriptor like @property. The difference is that
    when the property is assigned to, it is cached in the instance
    and the function is not called on that instance again.
    c             C   s   || _ t| | d S )N)r2   r   )r	   r2   r   r   r
   r3      s    zreadproperty.__init__c             C   s   |d kr| S |  |S )N)r2   )r	   r4   r5   r   r   r
   r6      s    zreadproperty.__get__N)r   r   r   r   r3   r6   r   r   r   r
   r7      s   r7   c              C   s   ddl } | d|  S )zA
    Returns the current time as a string in RFC3339 format.
    r   Nz%Y-%m-%dT%H:%M:%SZ)timeZstrftimeZgmtime)r8   r   r   r
   gmctime   s    r9   )	Interface)implementer)	Attributec               @   s   e Zd ZdS )r:   N)r   r   r   r   r   r   r
   r:      s   r:   c             C   s   dd }|S )Nc             S   s   | S )Nr   )cr   r   r
   dec   s    zimplementer.<locals>.decr   )Z_ifacer>   r   r   r
   r;      s    r;   c             C   s   | S )Nr   )sr   r   r
   r<      s    r<   )NFr   r   T)r   Z
__future__r   r   r   	functoolsr   r%   r   objectr   r   r#   r0   r7   r9   Zzope.interfacer:   r;   r<   ImportErrorr   r   r   r
   <module>   s2       
,)