
    Yf              	          U d Z ddlmZmZ ddlmZmZmZmZm	Z	 ddl
mZmZ  e	d          Z e	d          Z e	d          Zded	ee         d
efdZdeegef         dee         d
ee         fdZdee         dee         d
efdZdeeegef         d
eeegef         fdZdeegef         deegef         d
eegef         fdZ eej         e ee           ed                              Zeee         ged         f         ed<   deegef         deg ee         f         d
efdZdeegef         d
eg ef         fdZdS )z1
General functional-style helpers for disttrial.
    )partialwraps)	AwaitableCallableIterableOptionalTypeVar)Deferredsucceed_A_B_Cdefaultoptionalreturnc                     || S |S )z
    Get a definite value from an optional value.

    @param default: The value to return if the optional value is missing.

    @param optional: The optional value to return if it exists.
     )r   r   s     P/var/www/html/env/lib/python3.11/site-packages/twisted/trial/_dist/functional.pyfromOptionalr      s     O    	conditionxsc              #   8   K   |D ]} | |          r|V   dS dS )z
    :return: An iterable over C{xs} that stops when C{condition} returns
        ``False`` based on the value of iterated C{xs}.
    Nr   )r   r   xs      r   	takeWhiler      sC      
   9Q<< 	GGGGEE	 r   abc                 &   K   |  d{V  | d{V S )z
    Wait for one action to complete and then another.

    If either action fails, failure is propagated.  If the first action fails,
    the second action is not waited on.
    Nr   )r   r   s     r   sequencer   +   s*       GGGGGGG777777Nr   fc                 <     t                      fd            }|S )zc
    Create a function like another but with the order of the first two
    arguments flipped.
    c                      ||           S Nr   )r   r   r    s     r   gzflip.<locals>.g<   s    qAwwr   r   )r    r$   s   ` r   flipr&   6   s5     1XX    X Hr   fxfyc                 j     t                     t                     fd                        }|S )z
    Create a function that calls one function with an argument and then
    another function with the result of the first function.
    c                 ,      |                     S r#   r   )r   r'   r(   s    r   r$   zcompose.<locals>.gI   s     r""Q%%yyr   r%   )r'   r(   r$   s   `` r   composer+   C   sK     2YY
2YY     Y Y Hr   NdiscardResult	predicateactionc                 D   K   	  |             d{V } | |          s|S )z
    Call a function repeatedly until its result fails to satisfy a predicate.

    @param predicate: The check to apply.

    @param action: The function to call.

    @return: The result of C{action} which did not satisfy C{predicate}.
    TNr   )r-   r.   results      r   iterateWhiler1   X   s>      vxxy   	Mr   c                 *     ddt           f fd}|S )z
    Wrap a function with another that automatically passes an integer counter
    of the number of calls that have gone through the wrapper.
    r   r   c                  @    	            } dz  n
# dz  w xY w| S )N   r   )r0   counterr    s    r   r$   zcountingCalls.<locals>.gr   s6    	QwZZFqLGGGqLGGGGGs    )r   )r    r$   r5   s   ` @r   countingCallsr6   k   s<    
 Gr        Hr   )__doc__	functoolsr   r   typingr   r   r   r   r	   twisted.internet.deferr
   r   r   r   r   r   boolr   r   r&   r+   fromCoroutiner,   __annotations__r1   intr6   r   r   r   <module>r?      s     % $ $ $ $ $ $ $ C C C C C C C C C C C C C C 4 4 4 4 4 4 4 4WT]]WT]]WT]]
" 
 
 
 
 
 
	2$*- 	8B< 	HRL 	 	 	 	im 	" "    
Hb"Xr\" 
xR"'= 
 
 
 
"r" "r(: xb?Q     <C7GDDNNGGDMM**< <x2$78   d
#R2&'    &XseRi( Xb"f-=      r   