o
    0׾g*                     @   s   d Z ddlmZmZmZ ddlmZ G dd deZe ZdZ	dZ
e	e
fdd	Z	
				dddZdd ZG dd deZG dd deZG dd deZdd Zdd Zdd Zd
S ) z2
internal gevent utilities, not for external use.
    )print_functionabsolute_importdivision)	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   V/var/www/html/backend_erp/backend_erp_env/lib/python3.10/site-packages/gevent/_util.py__repr__   s   z_NONE.__repr__N)__name__
__module____qualname____doc__	__slots__r
   r   r   r   r	   r      s    r   )r   r   r   r   __annotations__)__dict__c              	   C   sd   |D ]}zt ||}W n	 ty   Y qw t| || q|D ]}t | |t ||i  q|| _| S )a7  
    Based on code from the standard library ``functools``, but
    doesn't perform any of the troublesome imports.

    functools imports RLock from _thread for purposes of the
    ``lru_cache``, making it problematic to use from gevent.

    The other imports are somewhat heavy: abc, collections, types.
    )getattrAttributeErrorsetattrupdate__wrapped__)wrapperwrappedassignedupdatedattrvaluer   r   r	   update_wrapper   s   r   NFr   __implements____all____imports__Tc                    s   |r|r fdd|D }n fdd|D }nt  j}g }|D ]!\}	}
|
tu r*q!|	|v r/q!|	dr9|	|vr9q!|
||	< ||	 q!|rLd|v rL|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)r   r   .0ksourcer   r	   	<genexpr>V   s    zcopy_globals.<locals>.<genexpr>c                 3   s    | ]
}|t  |fV  qd S r"   )r   r#   r&   r   r	   r(   X   s    __copy_globals)r   r   r   
startswithappend)r'   globs
only_namesignore_missing_namesnames_to_ignoredunder_names_to_keepcleanup_globsitemscopiedkeyr   r   r&   r	   r*   ;   s&   
r*   c                 C   s   | ds|dd}| d}|r||krdS ddlm} |r"dS ddl}ddl}|  |dt	 |
|}W d   n1 sDw   Y  |   | |j d| v r\| d= dS dS )	a  
    Import the C-accelerator for the *cname*
    and copy its globals.

    The *cname* should be hardcoded to match the expected
    C accelerator module.

    Unless PURE_PYTHON is set (in the environment or automatically
    on PyPy), then the C-accelerator is required.
    zgevent._gevent_czgevent._r   Nr   )PURE_PYTHONignoreimport_c_accel)r+   replacegetgevent._compatr6   	importlibwarningscatch_warningssimplefilterImportWarningimport_moduleclearr   r   )r-   cnamenamer6   r<   r=   modr   r   r	   r8   m   s*   



r8   c                   @       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 again.

    Contrast with `readproperty`.
    c                 C   s   ||j f| _t| | d S r"   )r   datar   r   funcr   r   r	   __init__   s   zLazy.__init__c                 C   s,   |d u r| S | j \}}||}||j|< |S r"   )rH   r   )r   instclass_rJ   rD   r   r   r   r	   __get__   s   

zLazy.__get__Nr   r   r   r   rK   rN   r   r   r   r	   rG      s    rG   c                   @   rF   )readpropertya  
    A non-data descriptor similar to :class:`property`.

    The difference is that the property can be assigned to directly,
    without invoking a setter function. When the property is assigned
    to, it is cached in the instance and the function is not called on
    that instance again.

    Contrast with `Lazy`, which caches the result of the function in the
    instance the first time it is called and never calls the function on that
    instance again.
    c                 C   s   || _ t| | d S r"   )rJ   r   rI   r   r   r	   rK      s   zreadproperty.__init__c                 C   s   |d u r| S |  |S r"   )rJ   )r   rL   rM   r   r   r	   rN      s   
zreadproperty.__get__NrO   r   r   r   r	   rP      s    rP   c                   @   s.   e Zd ZdZedd Zd	ddZdd ZdS )
LazyOnClassa8  
    Similar to `Lazy`, but stores the value in the class.

    This is useful when the getter is expensive and conceptually
    a shared class value, but we don't want import-time side-effects
    such as expensive imports because it may not always be used.

    Probably doesn't mix well with inheritance?
    c                 C   s   | |||j < dS )zCPut a LazyOnClass object in *cls_dict* with the same name as *func*N)r   )clscls_dictrJ   r   r   r	   lazy   s   zLazyOnClass.lazyNc                 C   s   |p|j | _|| _d S r"   )r   rD   rJ   )r   rJ   rD   r   r   r	   rK      s   
zLazyOnClass.__init__c                 C   s(   |d u r| S |  |}t|| j| |S r"   )rJ   r   rD   )r   rL   klassvalr   r   r	   rN      s
   
zLazyOnClass.__get__r"   )r   r   r   r   classmethodrT   rK   rN   r   r   r   r	   rQ      s    


rQ   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)timestrftimegmtime)rX   r   r   r	   gmctime   s   r[   c              	   C   sZ  | d dkrdS ddl }ddl}ddl}ddlm} | d }|ddd	| d d
g d| d< |g d |d}t|tsE|	d}n|}|	d}d|f }|j
|j| d ddddddddD ]F\}	}
t|	d}| }W d   n1 s|w   Y  |||\}}|rtd|	 t|	d}|| W d   n1 sw   Y  qddS )a  
    zest.releaser prerelease middle hook for gevent.

    The prerelease step:

        asks you for a version number
        updates the setup.py or version.txt and the
        CHANGES/HISTORY/CHANGELOG file (with either
        this new version
        number and offers to commit those changes to git

    The middle hook:

        All data dictionary items are available and some questions
        (like new version number) have been asked.
        No filesystem changes have been made yet.

    It is our job to finish up the filesystem changes needed, including:

    - Calling towncrier to handle CHANGES.rst
    - Add the version number to ``versionadded``, ``versionchanged`` and
      ``deprecated`` directives in Python source.
    rD   geventNr   )modulesnew_version	towncrierbuildz	--versionz--yesFupdate_history)gitrestorez--stagedzCHANGES.rsts2   .. (versionchanged|versionadded|deprecated):: NEXTasciis
   .. \1:: %sreporootsrcTr   )basedir	recursiveinclude_testsexcluded_modules
include_socheck_optionalrbzReplaced version NEXT inwb)reos
subprocessgevent.testingr]   
check_callcompile
isinstancebytesencodewalk_modulespathjoinopenreadsubnprintwrite)rH   ro   rp   rq   r]   r^   regexnew_version_bytesreplacementry   _fcontentsnew_contentscountr   r   r	   prereleaser_middle   sP   





r   c                 C   s   | d dkrdS d| d< dS )z
    Prevents zest.releaser from modifying the CHANGES.rst to add the
    'no changes yet' section; towncrier is in charge of CHANGES.rst.

    Needs zest.releaser 6.15.0.
    rD   r\   NFra   r   )rH   r   r   r	   postreleaser_beforeR  s   r   )NFr   r   T)r   
__future__r   r   r   r;   r   objectr   WRAPPER_ASSIGNMENTSWRAPPER_UPDATESr   r*   r8   rG   rP   rQ   r[   r   r   r   r   r   r	   <module>   s.   

23W